Hi
I’m trying to rewrite an HA automation to AppDaemon. I’m using Hue Dimmer switch for different functions in Home Assistant. The dimmer button value and update time is a sensor in HA and the automation calls a Python script, when both change.
- id: hue_kok_dimmer_automation
alias: Hue Kok dimmer automation
trigger:
- entity_id: sensor.kok_dimmer_lastupdated
platform: state
- entity_id: sensor.kok_dimmer_button_status
platform: state
action:
- service: python_script.hue_kok_dimmer
Name: sensor.kok_dimmer_button_status
Value: 1002 (it can be 1000, 1002, 2001, 2003 etc, always 4 integer )
Name: sensor.kok_dimmer_lastupdated
Value: 2018-07-18T17:29:28
I followed the totorial, but I can’t get it to work. The error i get is “TypeError: listen_state() missing 1 required positional argument: ‘entity’”. I tried without new=“1002” as i read in manual it should be optional, but the I get no response at all. I would prefer without the new=“1002” as just check witch button is pushed in the btn_action function.
The hello function works in AppDaemon, so it should be working properly.
Thanks
/Lars
import appdaemon.appapi as appapi
import datetime
from include import hue3 as hue
class HueKokkenButton(appapi.AppDaemon):
def initialize(self):
self.listen_state(self.btn_action,"sensor.kok_dimmer_button_status", new="1002")
def btn_action(self, entity, attribute, old, new, kwargs):
self.log("Kok Btn")
self.turn_on("switch.sonoff02")