Ah, I see.
I thought about something like that too at first, but I didn’t like that there is no “elegant” way of dealing with potentially varying number of changes.
The change1, change2… variables are one way to do this.
You probably have a loop in your app that then goes from 1 to “amount_of_changes” and processes the change variable.
But then you have to deal with cases where you delete changes from inside that range.
Or you start renumbering all the changeXs…
It would be cool if appdaemon would support something like
[app]
...
foo = 1
foo = 2
foo = 3
and you would get a list foo = [ '1', '2', '3' ] to use inside your app.
Hmm, it would seem like my AFP-connection via netatalk created .appledouble files matching each file, and that created the mess… A shame I can’t use AFP, then
File "/home/graham/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 424, in worker
function(entity, attr, old_state, new_state, ha.sanitize_state_kwargs(args["kwargs"]))
File "/home/homeassistant/.homeassistant/apps/etrv_diagnostics.py", line 44, in new_diagnostics
self.call_service("input_boolean.turn_on", entity_id = "input_boolean.etrv_329_diagnostic_mc_below")
File "/home/graham/lib/python3.5/site-packages/appdaemon/appapi.py", line 248, in call_service
self._check_service(service)
File "/home/graham/lib/python3.5/site-packages/appdaemon/appapi.py", line 34, in _check_service
raise ValueError("Invalid Service Name: {}".format(service))
ValueError: Invalid Service Name: input_boolean.turn_on
My service tab says that turn_on is a valid service for an input_boolean, so is it just not implemented in appDaemon?
I can change the state with set_state, so I have the names ok.
if obj["Motor current below expectation"]:
self.log("Turning on {}".format(self.mc_below))
self.set_state(self.mc_below, state = "on")
#self.call_service("input_boolean/turn_on", entity_id = self.mc_below)
else:
self.log("Turning off {}".format(self.mc_below))
self.set_state(self.mc_below, state = "off")
#self.call_service("input_boolean/turn_off", entity_id = self.mc_below)
Using self.state works fine, so self.mc_below has the correct entity_id, but the call_service does not change the state.
The output log is
2016-11-09 14:12:43.201203 INFO lounge_etrv_diagnostics: Turning on input_boolean.etrv_329_diagnostic_mc_below
2016-11-09 14:13:02.253100 INFO lounge_etrv_diagnostics: Turning off input_boolean.etrv_329_diagnostic_mc_below
I managed to make it work when I removed the capital letters from the name of the input_boolean in configuration.yaml. I’m new to HA, so I’m not sure if this is a bug or capital letters are not allowed.
im not new anymore but im still not sure about that
i never found anything about it in the documentation, but i learned the hard way not to use capitals.
and since then i even avoid numbers (had a problem with that somewhere to) and anything else except normal characters, if i can off course.
What would be the simplest way with appdaemon to save and restore the state of a set of lights? I want to save the current state of the lights when I trigger a specific scene and then restore it later. Any help would be appreciated!
You can use get_state() to grab the state info you are interested in and store it in a class variable. Then later on, you can use turn_on() to set the states back the way they were.