This seems like a possible bug to me but I am fairly new to AppDaemon so I thought I would ask if I am missing something.
I have the following app:
class AlarmOff(hass.Hass):
def initialize(self):
self.listen_state(self.someone_home, "person.XXXX", new = "home")
def someone_home(self, entity, attribute, old, new, kwargs):
self.log("appdaemon version: " + self.get_ad_version())
self.log("entity = " + str(entity))
self.log("attribute = " + str(attribute))
self.log("old = " + str(old))
self.log("new = " + str(new))
if self.get_state("alarm_control_panel.XXXX") == "armed_away":
self.log("Someone is home. Shutting off the alarm from appdaemon.")
self.call_service("alarm_control_panel/alarm_disarm",entity_id = "alarm_control_panel.XXXX")
If I check the log file at anytime after person.XXXX arrives home I see something like this:
2019-04-03 19:48:45.736356 INFO AlarmOff: attribute = state
2019-04-03 19:48:45.738526 INFO AlarmOff: old = home
2019-04-03 19:48:45.744738 INFO AlarmOff: new = home
2019-04-03 19:49:49.719596 INFO AlarmOff: appdaemon version: 3.0.2
2019-04-03 19:49:49.721849 INFO AlarmOff: entity = person.XXXX
2019-04-03 19:49:49.723982 INFO AlarmOff: attribute = state
2019-04-03 19:49:49.728326 INFO AlarmOff: old = home
2019-04-03 19:49:49.730595 INFO AlarmOff: new = home
2019-04-03 19:50:53.450009 INFO AlarmOff: appdaemon version: 3.0.2
2019-04-03 19:50:53.452638 INFO AlarmOff: entity = person.XXXX
2019-04-03 19:50:53.454874 INFO AlarmOff: attribute = state
2019-04-03 19:50:53.457109 INFO AlarmOff: old = home
2019-04-03 19:50:53.459496 INFO AlarmOff: new = home
2019-04-03 19:52:02.598946 INFO AlarmOff: appdaemon version: 3.0.2
2019-04-03 19:52:02.601602 INFO AlarmOff: entity = person.XXXX
2019-04-03 19:52:02.604014 INFO AlarmOff: attribute = state
2019-04-03 19:52:02.606542 INFO AlarmOff: old = home
2019-04-03 19:52:02.609069 INFO AlarmOff: new = home
2019-04-03 19:53:15.324774 INFO AlarmOff: appdaemon version: 3.0.2
2019-04-03 19:53:15.327048 INFO AlarmOff: entity = person.XXXX
2019-04-03 19:53:15.329344 INFO AlarmOff: attribute = state
2019-04-03 19:53:15.331526 INFO AlarmOff: old = home
2019-04-03 19:53:15.333622 INFO AlarmOff: new = home
2019-04-03 19:54:29.790176 INFO AlarmOff: appdaemon version: 3.0.2
2019-04-03 19:54:29.792464 INFO AlarmOff: entity = person.XXXX
2019-04-03 19:54:29.794752 INFO AlarmOff: attribute = state
2019-04-03 19:54:29.796874 INFO AlarmOff: old = home
2019-04-03 19:54:29.799251 INFO AlarmOff: new = home
2019-04-03 19:55:50.302093 INFO AlarmOff: appdaemon version: 3.0.2
2019-04-03 19:55:50.304560 INFO AlarmOff: entity = person.XXXX
2019-04-03 19:55:50.309518 INFO AlarmOff: attribute = state
2019-04-03 19:55:50.311979 INFO AlarmOff: old = home
2019-04-03 19:55:50.314231 INFO AlarmOff: new = home
2019-04-03 19:57:03.852409 INFO AlarmOff: appdaemon version: 3.0.2
2019-04-03 19:57:03.857981 INFO AlarmOff: entity = person.XXXX
2019-04-03 19:57:03.863057 INFO AlarmOff: attribute = state
2019-04-03 19:57:03.869587 INFO AlarmOff: old = home
Further details:
AppDaemon version: 3.02
Home Assistant Version: 0.90.2
Hassbian
Person.XXXX is tracked by one device tracker using GPSLogger
The Logbook shows exactly one transition to/from not_home/home when person.XXX arrives or leaves. This has been 100% reliable on this particular phone for several weeks.
The error log is clear.
Things I am questioning:
-
Based on the AppDaemon documentation I would expect âoldâ to log something other than home and ânewâ to log home (a change in state) yet they both show home.
-
I would expect the callback to run one time when person XXX arrives yet it is obviously running over and over. As you can see these executions are slightly more than 1 minute apart. GPSLogger is set to update location every one minute.
I think I can work around this by calling cancel_listen_state when the callback runs and calling listen_state again when person_XXXXâs state changes to "not_home. However if I am making a mistake I would like to learn what that is and if there is a bug I would like to report it. I would appreciate any input.