Hi,
Have being trying to get my app to accept multiple entities (lights) so they can all be changed at the same time.
my Apps.yaml is this
notify_door_open_closed_front: module: notify_door_open_closed class: NotifyDoorOpenClosed door : binary_sensor.door_window_sensor_158d0001e59f03 notifymessage: "The Front Door " lights: - light.study_strip_light - light.family_color_light
I am looping through as per the example in Docs ie:
class NotifyDoorOpenClosed(appapi.AppDaemon):
def initialize(self):
# Subscribe to sensors
self.listen_state(self.doorChangeDected, self.args["door"])
def doorChangeDected(self, entity, attribute, old, new, kwargs):
if new == "on" or new == "open":
state = "open"
else:
state = "closed"
if state == "open":
self.log("{} has opened".format(self.args["door"]))
self.call_service("notify/notify", message = self.args["notifymessage"]+ "is really Open")
for light in self.args.lights:
self.turn_on(light,effect = "twinkle")
if state == "closed":
self.log("{} has closed".format(self.args["door"]))
self.call_service("notify/notify", message = self.args["notifymessage"]+ "is really Closed")
for light in self.args.lights:
self.turn_off(light)
I am getting this erorr in logs
2018-02-10 18:24:14.721629 WARNING Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 512, in worker
utils.sanitize_state_kwargs(args["kwargs"]))
File "/config/appdaemon/apps/notify_door_open_closed.py", line 35, in doorChangeDected
for light in self.args.lights:
AttributeError: 'dict' object has no attribute 'lights'
Everything works well if I have single Light defined and remove the For loop, but can’t get this working with multiple entities.
I am using AppDaemon 2