Author Topic: Option to save state of scene or device on restart  (Read 187 times)

Offline ninkasi

  • Sr. Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
Option to save state of scene or device on restart
« on: February 02, 2017, 05:57:39 pm »
I've had my Vera now for a while and like it a lot - there is one thing I'd like to improve though. I have some scenes where (for example) a light will go on after detecting motion and then after a set amount of time it will go off. If motion is detected before the light goes off, then the timer is reset. Or I have other scenes that, for example, when on vacation turn a light on a few minutes before sunset and then off again sometime after midnight. You get the general idea. Basically this is impacting on wife acceptance factor when she opens the pantry door and the light doesn't always come on. Or it comes on and then goes off again after a couple of seconds.

Now I believe the issue/challenge is when the Vera unit or Luup restarts for any reason, the current variable state is lost and/or the scene is no longer active. Basically any scene that runs for more than a few seconds (eg one that has a delay in the script) I've found can be unreliable. Saying that, they will work a lot of the time - just not always.

Now Luup restarts shouldn't be that often, and I've scheduled an automatic Vera reboot in the early morning to make sure that any process that may go out of control is cleared, but restarts do happen during the day for various reasons (me making a change, some process having an issue, etc). End result is sometimes the lights either don't turn on as expected or remain on or off. I've got around this in various ways - eg breaking the vacation scene into two scenes - one to turn the light on, and another to turn it off. Ideally however I would like to be able to save the current state of scenes etc so that when the Vera restarts it's back the way it was.

FWIW I used to do this way back in the day with my old home automation system (MisterHouse - written in perl), so I know it's not impossible. In my case I was using mainly X10 kit which couldn't be polled for current status, so by saving the state of a device or script in a hash prior to restarting, when the system came back it knew which lights were on or off etc.

I've had a hunt and haven't found anything like this with the Vera. Assuming it's not there already, this could be done in two ways I suspect - one would be fairly resource intensive where the current state of everything is continually written to a file that could be reloaded on starting. This I suggest would be bad - not only would it impact on performance, it could also end up causing the Vera to go into an endless loop of death if the reason for it restarting was due to something in the current state.

My suggestion would be an option on each scene or device where you can choose to save the current state on restart. When Luup or the Vera is restarted, those devices or scenes with this flag enabled would have their state written to a file that on restart  would be loaded up - so Vera then knows, for example, that the scene "Vacation - Lights" is running and turns the lights off when required. Perhaps a failsafe could be included where if Vera/Luup restarts three times in a row within 5 minutes (say) the saved states are cleared.

By the way I know that you shouldn't need to be able to save the state of a Z-Wave device as the hub will poll it and get that, but this would be of use for those devices that don't support that - such as legacy X10 kit or virtual devices.

I suspect this probably could be done by tacking on some Luup code to the scene itself, but it would be nice if it was 'built in' to the gui itself....

Just a thought.


Offline ember1205

  • Sr. Member
  • ****
  • Posts: 297
  • Karma: +4/-17
Re: Option to save state of scene or device on restart
« Reply #1 on: February 02, 2017, 11:39:26 pm »
Add variables to the devices and save state information when you make the change. Then, on any restart of the unit or Lua or whatever, you can have a sort of "master scene" that reads those settings and restores them.

Lua shouldn't be restarting on you, however. If that's cycling, there is likely some other issue that needs to be chased down and corrected.