Restore virtual sensor state

We’re using a number of virtual sensors. For example, we have CLIPGenericFlag sensors for lighting/heating away mode.

While we were away, we unfortunately had a power cut. It seems the sensors restored to their default value of false when that happened. Obviously not ideal for this use case - we only realised on our return.

Is this expected behaviour for virtual sensors or a bug/feature request? It would be great if virtual sensors restored their state on restart.


Yes currently this is how it works when loading CLIP sensors, and since 2018 in particular for CLIPGenericFlag and CLIPGenericStatus sensors. Related commit: c06a8b, before that all CLIP sensors didn’t restore state.

It is a interesting case in general not only CLIP sensors. We can’t / shouldn’t just change the way it loads on startup since this may break other setups that count on this. But we can add a new attribute for sensors to specify if it should restore the last known value on startup.

I need to think about this a bit more and talk to the other devs but it would be very useful in general also for DDF based sensors.

Many thanks for clarifying @manup.

As per the comment in the code on that commit, it’d be interesting to know why those two CLIP sensor types are unique in this way. I’m not sure in what use case it would be beneficial to not restore values on startup. But there must be some.

Appreciate any further work on this area. In the meantime I might switch to using a different type of CLIP sensor, even if they don’t feel as appropriate.

Could this fix the “window sensor show open after deconz restart” issue?