Hi everyone,
I’m a beginer in Python and I spend a lot of time to solve an issue I have by myself without success. It is time to me to ask for some help
When I switch some lights in a Appdaemon python script, even if the command has been sent like:
self.turn_on(group.spots)
sometimes the device doesn’t turn on.
So I tried to implement a simple function that checks that the light is on and if not resend the command 1s later, but after many attempts all of my trials are failing… Appdaemon finishes by crashing.
def switched_with_check(self,entity,state):
if self.handle:
if self.timer_running(self.handle):
self.cancel_timer(self.handle)
self.handle = None
if state=="on":
self.turn_on(entity)
else:
self.turn_off(entity)
if self.get_state(entity)!=state:
self.handle=self.run_in(self.switched_with_check(entity, state), 1)
else:
self.cancel_handle(self.handle)
I get the following messages in my logs:
2024-12-05 13:58:20.602480 WARNING AppDaemon: Excessive time spent in callback 'cinema_mode() in generic', Thread 'thread.thread-0' - now complete after 34.60114 seconds (limit=10)
2024-12-05 13:58:20.839265 CRITICAL AppDaemon: Thread thread-0 has died
2024-12-05 13:58:20.841827 CRITICAL AppDaemon: Pinned apps were: ['generic']
2024-12-05 13:58:20.842827 CRITICAL AppDaemon: Thread will be restarted
2024-12-05 13:58:20.843906 INFO AppDaemon: Adding thread 0
2024-12-05 13:58:21.859806 CRITICAL AppDaemon: Thread thread-0 has died
2024-12-05 13:58:21.860919 CRITICAL AppDaemon: Pinned apps were: ['generic']
2024-12-05 13:58:21.861892 CRITICAL AppDaemon: Thread will be restarted
2024-12-05 13:58:21.862786 INFO AppDaemon: Adding thread 0
i tried some variants with async function etc… but none of my trials worked.
I would really appreciate all the help you could give me.
Thanks in advance.