turboc
(Chip Cox)
February 4, 2017, 12:20am
1
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'])
2 Likes
turboc
(Chip Cox)
February 4, 2017, 12:48am
3
That’s what I’m doing now. Just thought the other would be a nice enhancement.
aimc
(Andrew Cockburn)
February 4, 2017, 1:04pm
4
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