from appdaemon.entity import Entity from appdaemon.plugins.hass.hassapi import Hass class AqaraSwitch(Hass): def initialize(self): self.log(f'Initializing Aqara Switch for {self.switch.friendly_name}') self.button.listen_state(self.handle_button_press, new=self.args.get('action', 'single')) @property def switch(self) -> Entity: return self.get_entity(self.args['switch']) @property def button(self) -> Entity: return self.get_entity(self.args['button']) def handle_button_press(self, entity: str, attribute: str, old: str, new: str, **kwargs): # self.log(f'{new}') self.switch.toggle()