reorg
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
import json
|
||||
|
||||
from appdaemon.entity import Entity
|
||||
from appdaemon.plugins.hass.hassapi import Hass
|
||||
from appdaemon.plugins.mqtt.mqttapi import Mqtt
|
||||
import json
|
||||
|
||||
|
||||
class SleepSetter(Hass, Mqtt):
|
||||
def initialize(self):
|
||||
assert self.entity_exists(entity_id=self.variable), f'{self.variable} does not exist'
|
||||
self.variable_entity.listen_state(callback=self.handle_state)
|
||||
self.setup_buttons()
|
||||
self.log(f'{self.variable} can be set using {self.button}, currently {self.state}')
|
||||
|
||||
def setup_buttons(self):
|
||||
if isinstance(self.button, list):
|
||||
for button in self.button:
|
||||
self.setup_button(button)
|
||||
else:
|
||||
self.setup_button(button)
|
||||
|
||||
self.log(f'{self.variable} can be set using {self.button}, currently {self.state}')
|
||||
|
||||
def setup_button(self, name: str):
|
||||
topic = f'zigbee2mqtt/{name}'
|
||||
self.mqtt_subscribe(topic, namespace='mqtt')
|
||||
|
||||
Reference in New Issue
Block a user