Hello,
I just tried to play around AppDaemon and wanted to write my first app. However, I have came to a big problem with registering callback on state change. Could someone here help me with it?
Following some examples I was always getting following error:
2018-03-15 21:10:15.998168 WARNING AppDaemon: Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1927, in check_app_updates
self.init_object(app)
File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1477, in init_object
self.objects[name]["object"].initialize()
File "/conf/apps/test.py", line 6, in initialize
self.listen_state(self.motion, "binary_sensor.drive", new = "on")
TypeError: listen_state() missing 1 required positional argument: 'entity'
So I have turned back to API documentation, which claims I cane use listen_state with only callback as a parameter, but it still throws:
2018-03-15 21:26:43.262855 WARNING AppDaemon: Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1927, in check_app_updates
self.init_object(app)
File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1477, in init_object
self.objects[name]["object"].initialize()
File "/conf/apps/test.py", line 14, in initialize
self.listen_state(self, self.my_callback)
TypeError: listen_state() missing 1 required positional argument: 'entity'
What do I do wrong about registering the callback?
This tutorial is written for appdaemon version 2. There have been some changes in appdaemon 3. That doesnt effect much from this tutotial, but 2 things should be changed if you use version 3: when you read the line:
import appdaemon.appapi as appapi
replace that with:
import appdaemon.plugins.hass.hassapi as hass
and when you see:
appapi.AppDaemon
replace that with:
hass.Hass