I’ve just started to organize my automations through appdaemon, so I’m still learning. My initial plan was to simplify repeated scenarios, like power saving lights (turns off after x min) and motions detection.
I’ve created a PowersavingLight class that works well. It just uses a countdown timer to turn the lights off when the timer reaches 0. The timer is controlled by input_number entities in the UI and a cleaning mode switch that disables the timer. I was hoping to build off that functionality for certain lights that should respond to motion. The idea was to create a new class, MotionLight, that inherits the PowersavingLight class but I seem to be running into an error.
FYI, my python is quite rusty, but I thought the inheritance process works as follows.
import hassapi as hass
import globals
import os
import datetime
class PowersavingLight(hass.Hass):
DEFAULT_TIMER_DURATION_M = 30 # MIN
TIMER_PERIOD_S = 5 # SECONDS
SEC_PER_MIN = 60
def initialize(self):
self.description = "EMPTY"
self.duration = self.DEFAULT_TIMER_DURATION_M
self.duration_id = None
self.timer_handle = None
self.time_remaining = None
self.light = None
self.cleaning_mode = "off"
etc....
import hassapi as hass
import globals
import powersaving_lights
#
# Motion activate lights. Extends Power Saving lights
#
class MotionLight(PowersavingLight):
def initialize(self):
if "motion_sensor" in self.args:
self.motion_sensor = self.args["motion_sensor"]
Here’s the error
2020-11-10 09:34:12.683826 INFO AppDaemon: Reloading Module: /conf/apps/motion_lights.py
2020-11-10 09:34:12.683920 INFO AppDaemon: Loading App Module: motion_lights
2020-11-10 09:34:12.685086 INFO AppDaemon: Initializing app motion_lights using class MotionLight from module motion_lights
2020-11-10 09:34:12.686218 WARNING motion_lights: ------------------------------------------------------------
2020-11-10 09:34:12.686494 WARNING motion_lights: Unexpected error initializing app: motion_lights:
2020-11-10 09:34:12.686730 WARNING motion_lights: ------------------------------------------------------------
2020-11-10 09:34:12.687046 WARNING motion_lights: Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/appdaemon/app_management.py", line 907, in check_app_updates
await self.init_object(app)
File "/usr/local/lib/python3.8/site-packages/appdaemon/app_management.py", line 294, in init_object
"object": app_class(
TypeError: MotionLight() takes no arguments
What am I missing?