genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
388 stars 154 forks source link

Security sensors & door/windows modules fail to retain settings on service restart. #332

Closed tuicemen closed 5 years ago

tuicemen commented 5 years ago

I've been attempting to find a commonality behind this as occasionally the info will magically appear after the devices reporting in. I suspect HG is waiting to see if these still exist however if this is the case it should display the names once the sensor has reported in and it doesn't all the time. Also if you have the device set to "use as a security sensor" and or "also trigger when armed home" this values are not reloaded with these not loading their settings the security info widget never displays any history and if these trigger macros they fail. I think I may finally have the steps to recreate Complete loss of settings seems to be caused if the OS reboots or shuts down prior to all modules checking in. I believe just a service restart doesn't lose settings nor does just a OS reboot, however names and settings never appear until the module has checked it.

If one of these sensors is tripped prior to HG actually seeing it and loading saved settings any macros configured with it as a trigger will I suspect fail even though setting are there just not loaded.

Occasionally module names and settings are lost completely. I've yet unable to accurately recreate this though I suspect it is due to a reboot or service restart prior to the modules no longer appearing as undefined.

Expected behavior

Sensors and door/window modules to retain and load settings after a service restart with out waiting for a heart beat and browser refresh to load the info of each.

Actual behavior

Sensor & door/window modules fail to load names and settings mediately after a reboot or service restart. You either have to wait for a heartbeat from the module or go around and press the test button then refresh your browser The modules do appear in the group they were added to and in the correct locations just as undefined If the OS reboots before the modules check in, some times saved settings and module names are lost

Steps to reproduce the problem starting from a fresh install

  1. enable X10 RF virtual modules mapper
  2. add a few sensors and or door/window sensors once seen to a group
  3. add name and info for modules and save
  4. reboot OS or restart service doesn't matter. 5.Open or refresh HG web interface and group modules were added to
  5. Modules will show as "Undefined (undefined)} and as "unknown module"
  6. trip the physical module so the RF virtual mapper sees them
  7. refresh the browser to have the modules display names and security settings as saved

Specifications

Additional configuration notes

These are modules all X10 security modules

genemars commented 5 years ago

This might be related to a known issue about to the way HG is shutdown.

If HG is not shutdown gracefully, it will probably not save the last changes to the configuration.

HG does not save the configuration at every single change. This is mainly done to prevent stress of file system and mainly to preserve SD card on low energy devices.

The configuration is only saved if:

So if you turn off or reset the operating system all of sudden, the latest configuration changes will be likely to be lost since the HomeGenie.SaveData() will not be called.

tuicemen commented 5 years ago

that makes sense And I'll keep a better eye on this as I know I have made backups and still lost some security devices. However I may have added one or two after a backup. This should not affect the lost of names and settings for the others though. Can you explain why a sensor must check in before the names and saved settings appear?

genemars commented 5 years ago

Can you explain why a sensor must check in before the names and saved settings appear?

this is because in order to prevent dead modules or wrong status report, the X10 driver requires that security modules must check-in in order to be added to the modules list. Additionally the X10 security sensors can have different IDs that can only be determined when the first signal is sent.

So anytime you reset hg you can press the button on the sensor to make it register, or alternatively just wait for the periodic ACK signal the sensors send. They will be reassigned to the previous instance of the module.

In fact HG will not delete "dead" X10 modules and will revive them as soon as the X10 driver adds them again to the modules list. This will work unless you cause a configuration save before the sensors check-in back (in that case HG will purge out all dead modules).

tuicemen commented 5 years ago

thanks I've renames and set the security preferences and then did a back up so I'll keep an eye on this over the next few days The control+c signal can it be set as a crontab instance?

tuicemen commented 5 years ago

@genemars I've been monitoring these for a few days now and even updated to the latest version. The one thing I noticed is you must refresh your browser in order to get the sensors to populate correctly. Not a big deal but I'd have thought they would be seen and updated without a browser refresh being required as their status changes without a refresh being required.

tuicemen commented 5 years ago

@genemars with the latest stable 18 build HG doesn't display the security modules names after re-detecting the modules after a reboot. Both using the cm19 and the cm15 behave the same. prior to this the modules would display their given names once redetected by the cm15.