[solved] Appdaemon script stopped working

After a few upgrades (Home Assistant (Core) from 0.104.x to 0.106.2; AppDaemon from 3.0.5 to 4.0.3), my script for integrating device trackers has been acting odd.

The last working version (which has been unaltered from August to now) is this.

At present, the life360 and google maps device_trackers don’t seem to update (except life360 did seem to update for one person an hour or so ago). The “Ping” tracker seems to work in the AD script, at least for me it has updated the “meta tracker”. but only for me.

The app seems to crash continuously, the appdaemon log shows (repeatedly):

2020-02-29 23:46:25.225704 INFO AppDaemon: Reloading Module: /conf/appdaemon/apps/device_tracker/meta_device_tracker.py
2020-02-29 23:46:25.229088 INFO AppDaemon: Initializing app meta_tracker using class MetaTracker from module meta_device_tracker
2020-02-29 23:46:50.686623 INFO AppDaemon: Terminating meta_tracker
2020-02-29 23:46:50.690260 INFO AppDaemon: Reloading Module: /conf/appdaemon/apps/device_tracker/meta_device_tracker.py
2020-02-29 23:46:50.693693 INFO AppDaemon: Initializing app meta_tracker using class MetaTracker from module meta_device_tracker
2020-02-29 23:46:50.707424 WARNING AppDaemon: Log formatting error - 'not all arguments converted during string formatting'
2020-02-29 23:47:52.100706 INFO AppDaemon: Terminating meta_tracker
2020-02-29 23:47:52.104361 INFO AppDaemon: Reloading Module: /conf/appdaemon/apps/device_tracker/meta_device_tracker.py
2020-02-29 23:47:52.108092 INFO AppDaemon: Initializing app meta_tracker using class MetaTracker from module meta_device_tracker
2020-02-29 23:49:13.696024 INFO AppDaemon: Terminating meta_tracker

with nothing in the error log.

I can’t really see what should have broken it. Other AppDaemon scripts work fine (after upgrading from 4.0.2 -> 4.0.3 at least), and the individual device trackers seem t work fine. And I couldn’t see anything in the release notes that would make this make sense for me…

Any idea if there’s anything I missed?

“not all arguments converted during string formatting” sounds like a missing quote (") somewhere?

@sj3fk3 Thanks, but that might have been from when I was messing with the script, so I don’t think that part is relevant.

It started after having worked fine for 6 months. So something happened after these upgrades, and before I started changed anything in the script.

If I manually change the state of my device trackers (e.g. life360), then it runs, and updates the meta_tracker. But It won’t do it on its own; only the ping device tracker seems to update. Maybe there was a change in one of the updates (Appdaemon or Home Assistant) to how an “update” that doesn’t change the state is handled? E.g. if device_tracker.life360 is updated, but the state doesn’t change, it seems (my best guess for now) that the AppDaemon script doesn’t fire via the self.listen_state anymore. Would that make sense? That this has changed in those updates?

I’m currently noticing issues with the life360 and google maps device trackers.

OK, so I’ve found out what’s going on. This is a change between AppDaemon 3.x and 4.x.

From 4.x, the “listen_state” will only trigger callback if the new state is different from the old state, not if any other attributes change. So this:

self.listen_state(self.callback, 'device_tracker.something')

won’t trigger self.callback unless the new state is different. The workaround is using the attribute=all, so:

self.listen_state(self.callback, 'device_tracker.something', attribute='all')

Now any attribute change will trigger self.callback .

1 Like

I also did an upgrade from Appdaemon 3 to 4 and run into the same issue. My motion sensors (Xiaomi Aqara Human Body Sensor) initially triggered the lights but then any continous movement afterwards (which results in another message while the sensor entity stays at “detected”) didn’t restart my timers. Although I set force_update to true.

So, the simple example self.listen_state(self.motion_detected_callback, motion_entity, new="on") IMHO doesn’t work with the Aqara motion sensors that stay “on” for 60 seconds and AppDaemon 4. It only works if after 60 seconds the sensor turns back to “off”, but not for a continous movement.

Good to know!

I use the Aqara sensors, but I have my timers set up to only start when movement stops, so I’ve never noticed this issue with these sensors:

https://github.com/Aephir/Home_Assistant/blob/023d96eb5b880509ab52d64b86da988a6f0cd167/appdaemon/apps/motion/kitchen_lights.py

That said, what Andrew Cockburn said in the Discord channel when I commented that the “new behavior” was fine, as long as there was a workaround:

Cool - if there wasn’t a workaround we would add one :wink:

So if you really need a workaround, you could try asking nicely?