Appdaemon enhancement request

In the listen_state type of calls, we can already expand what we want by listing just the device type. How about letting us pass in a list of devices we want state change notifications on.

devices=[“light.den_fan_light”,“switch”,“light.front_porch_light”]

self.listen_state(“self.statecallback”,devices)

Why not do this?

for app_name in ['light.den_fan_light', 'switch', 'light.front_porch_light']:
    self.listen_state(self.statecallback, app_name)

If you’re worried about handles not being maintained…

handle_library = {}

for app_name in ['light.den_fan_light', 'switch', 'light.front_porch_light']:
    handle_library[app_name] = self.listen_state(self.statecallback, app_name)

...

cancel_listen_state(handle_library['some_app_name'])
  • SN
2 Likes

That’s what I’m doing now. Just thought the other would be a nice enhancement.

Feel free to add it as an issue and I’ll think about it. As SN demonstrated though at best it will save you one line of code :wink: