I’m working on basic scripts with version 3.0 following the tutorial but am having problems.
Here is my apps.yaml file:
curio:
module: curio
class: Curio_cabinet_light
Here is the python script:
import appdaemon.plugins.hass.hassapi as hass
import datetime
class Curio_cabinet_light(hass.Hass):
def initialize(self):
#
# Configure two callbacks. The first occurs 30 minutes after sunset. The
# second occurs at 10PM tonight (this assumes that sunset + 30 minutes always
# occurs before 10PM.
#
self.run_at_sunset(self.light_on, offset = 30 * 60)
when = datetime.datetime.combine(datetime.date.today(), datetime.time(22, 0, 0))
self.run_at(self.light_off, when)
def light_on(self, entity, attribute, old, new, kwargs):
"""
Post-sunset callback
"""
self.turn_on("light.curio_cabinet_light")
def light_off(self, entity, attribute, old, new, kwargs):
"""
Time to turn off the light callback
"""
self.turn_off("light.curio_cabinet_light")
Here is the error message I get:
2018-03-23 20:10:59.011623 WARNING AppDaemon: ------------------------------------------------------------
2018-03-23 22:00:00.004370 WARNING AppDaemon: ------------------------------------------------------------
2018-03-23 22:00:00.005004 WARNING AppDaemon: Unexpected error in worker for App curio:
2018-03-23 22:00:00.005533 WARNING AppDaemon: Worker Ags: {'kwargs': {}, 'name': 'curio', 'function': <bound method Curio_cabinet_light.light_off of <curio.Curio_cabinet_light object at 0x5e7952d0>>, 'type': 'timer', 'id': UUID('be782a26-2fce-4285-9bae-8237326d0dc1')}
2018-03-23 22:00:00.005960 WARNING AppDaemon: ------------------------------------------------------------
2018-03-23 22:00:00.006681 WARNING AppDaemon: Traceback (most recent call last):
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 529, in worker
funcref(self.sanitize_timer_kwargs(app, args["kwargs"]))
TypeError: light_off() missing 4 required positional arguments: 'attribute', 'old', 'new', and 'kwargs'
Is there something obvious I’m doing wrong?
I also have an unrelated question about appdaemon in general. I like the HA card that shows the automations and has switches for each one. Is there a way to present the appdaemon apps in a similar card with switches?