Mohlsson / ReplayLightsHistory

AppDaemon App for Home Assistant to replay light switch history when no one is home.
Apache License 2.0
29 stars 5 forks source link

Pulling sensors and automations #3

Closed w1tw0lf closed 3 years ago

w1tw0lf commented 4 years ago

How would you prevent it from pulling sensors and automations with the word light in ?

`2020-02-02 20:29:17.100828 INFO AppDaemon: App initialization complete 2020-02-02 20:29:22.063329 INFO replay_lights: scheduling 2020-02-02 20:29:22.185856 INFO replay_lights: scheduling sensor.family_bathroom_light_uptime to 51296 at 2020-02-02 20:30:43.689013 2020-02-02 20:29:22.218896 INFO replay_lights: scheduling sensor.family_bathroom_light_uptime to 51356 at 2020-02-02 20:31:43.682265 2020-02-02 20:29:22.226049 INFO replay_lights: scheduling light.main_bedroom_led to on at 2020-02-02 20:32:34.216056 2020-02-02 20:29:22.246465 INFO replay_lights: scheduling sensor.family_bathroom_light_uptime to 51416 at 2020-02-02 20:32:43.689536 2020-02-02 20:29:22.263121 INFO replay_lights: scheduling light.main_bedroom_led to off at 2020-02-02 20:33:19.831963 2020-02-02 20:29:22.268674 INFO replay_lights: scheduling sensor.family_bathroom_light_wifi_signal to -71 at 2020-02-02 20:33:34.609945 2020-02-02 20:29:22.281471 INFO replay_lights: scheduling sensor.family_bathroom_light_uptime to 51476 at 2020-02-02 20:33:43.690223 2020-02-02 20:29:22.286729 INFO replay_lights: failed to parse ('{"name": "Main bedroom lights off", "entity_id": "automation.main_bedroom_lights_off"}',) 2020-02-02 20:29:22.288823 INFO replay_lights: failed to parse ('{"domain": "light", "service": "turn_off", "service_data": {"entity_id": "light.main_bedroom_lamp_left"}}',) 2020-02-02 20:29:22.291368 INFO replay_lights: failed to parse ('{"domain": "light", "service": "turn_off", "service_data": {"entity_id": "light.main_bedroom_lamp_right"}}',) 2020-02-02 20:29:22.297558 INFO replay_lights: scheduling automation.main_bedroom_lights_off to on at 2020-02-02 20:22:22.547041 2020-02-02 20:29:22.301428 WARNING replay_lights: ------------------------------------------------------------ 2020-02-02 20:29:22.302931 WARNING replay_lights: Unexpected error in worker for App replay_lights: 2020-02-02 20:29:22.303518 WARNING replay_lights: Worker Ags: {'id': 'a6aec789b58942c896e7d9970c7b45a7', 'name': 'replay_lights', 'objectid': 'ee9f8c889c544da8b3ac4f62b9d23e30', 'type': 'scheduler', 'function': <bound method ReplayLights.scheduleNextEventBatch of <replay_lights.ReplayLights object at 0x7f700a00ea60>>, 'pin_app': True, 'pin_thread': 1, 'kwargs': {'interval': 3600, 'thread_id': 'thread-1'}} 2020-02-02 20:29:22.303978 WARNING replay_lights: ------------------------------------------------------------ 2020-02-02 20:29:22.306630 WARNING replay_lights: Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 766, in worker funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"])) File "/config/appdaemon/apps/replay_lights.py", line 32, in scheduleNextEventBatch self.run_at(self.executeEvent, event_trig_at, entity_id = entity_id, event_new_state = event_new_state) File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 191, in inner_sync_wrapper f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs)) File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 285, in run_coroutine_threadsafe result = future.result(self.AD.internal_function_timeout) File "/usr/lib/python3.8/concurrent/futures/_base.py", line 432, in result return self.get_result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result raise self._exception File "/usr/lib/python3.8/site-packages/appdaemon/adapi.py", line 2248, in run_at raise ValueError( ValueError: replay_lights: run_at() Start time must be in the future

2020-02-02 20:29:22.307277 WARNING replay_lights: ------------------------------------------------------------ 2020-02-02 20:30:44.009750 WARNING AppDaemon: Unknown service (default/light/turn_51296) in call_service from replay_lights 2020-02-02 20:30:44.013352 INFO replay_lights: turned sensor.family_bathroom_light_uptime 51296 2020-02-02 20:30:48.065302 INFO AppDaemon: New client Admin Browser connected 2020-02-02 20:31:44.014324 WARNING AppDaemon: Unknown service (default/light/turn_51356) in call_service from replay_lights 2020-02-02 20:31:44.018421 INFO replay_lights: turned sensor.family_bathroom_light_uptime 51356`

Mohlsson commented 4 years ago

Well, I haven't really made this bullet proof as you can see. In my system I don't have anything else with 'light' in the name except for the light group and that is explicitly excluded. A better solution may be to create a specific group of identities that can be matched with in the event database. I don't have too much time right now to dig into this but I will try it when my day job stops also being my evening/weekend job.

w1tw0lf commented 4 years ago

No Stress, think I might have solved it.

AND event_data like "%light%" AND NOT event_data like "%sensor%" AND NOT event_data like "%automation%" AND NOT event_data like "%led%"

Seems to have fixed it. Will leave this one open for now,

0n3man commented 4 years ago

This issue might be fixed with the updates that were recently made. Looks like the app is also now available through NACS.