toggle stuff
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import json
|
||||
from copy import deepcopy
|
||||
|
||||
from appdaemon.plugins.hass.hassapi import Hass
|
||||
from appdaemon.plugins.mqtt.mqttapi import Mqtt
|
||||
|
||||
# from ..room_control.room_control import RoomController
|
||||
|
||||
class AqaraCube(Mqtt):
|
||||
class AqaraCube(Hass, Mqtt):
|
||||
def initialize(self):
|
||||
self.set_namespace('mqtt')
|
||||
topic = f'zigbee2mqtt/{self.args["cube"]}'
|
||||
self.mqtt_subscribe(topic)
|
||||
self.listen_event(self.handle_event, "MQTT_MESSAGE", topic=topic)
|
||||
self.mqtt_subscribe(topic, namespace='mqtt')
|
||||
self.listen_event(self.handle_event, "MQTT_MESSAGE", topic=topic, namespace='mqtt')
|
||||
self.log(f'Listening for cube events on: {topic}')
|
||||
|
||||
self.app = self.get_app(self.args['app'])
|
||||
@@ -39,12 +40,9 @@ class AqaraCube(Mqtt):
|
||||
self.call_service('scene/turn_on', entity_id=description, namespace='default')
|
||||
self.log(f'Turned on {description}')
|
||||
|
||||
elif description == 'toggle':
|
||||
cause = f'{action} from {self.args["cube"]}'
|
||||
if self.app.entity_state:
|
||||
self.app.deactivate(cause=cause)
|
||||
else:
|
||||
self.app.activate(cause=cause)
|
||||
elif description.startswith('toggle'):
|
||||
cause = f'{self.args["cube"]} {action}'
|
||||
self.app.toggle(kwargs={'cause': cause})
|
||||
|
||||
# def handle_rotate_right(self, payload):
|
||||
# self.log(f'{self.args["cube"]}: Rotate right')
|
||||
|
||||
Submodule apps/room_control updated: afc5e45642...148645094a
@@ -1,6 +1,7 @@
|
||||
bathroom:
|
||||
module: room_control
|
||||
class: RoomController
|
||||
ref_entity: light.bathroom
|
||||
off_duration: '00:05:00'
|
||||
states:
|
||||
- time: '05:00:00'
|
||||
@@ -35,7 +36,6 @@ bathroom_button:
|
||||
module: button
|
||||
class: Button
|
||||
app: bathroom
|
||||
ref_entity: light.bathroom
|
||||
button: Bathroom Button
|
||||
|
||||
bathroom_motion:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
bedroom:
|
||||
module: room_control
|
||||
class: RoomController
|
||||
ref_entity: light.bedroom
|
||||
off_duration: '00:05:00'
|
||||
states:
|
||||
- time: 'sunrise - 03:00:00'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
kitchen:
|
||||
module: room_control
|
||||
class: RoomController
|
||||
ref_entity: light.kitchen
|
||||
off_duration: '00:10:00'
|
||||
ha_button: input_button.activate_kitchen
|
||||
states:
|
||||
@@ -40,7 +41,6 @@ kitchen_button:
|
||||
module: button
|
||||
class: Button
|
||||
app: kitchen
|
||||
ref_entity: light.kitchen
|
||||
button: Kitchen Button
|
||||
|
||||
kitchen_motion:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
living_room:
|
||||
module: room_control
|
||||
class: RoomController
|
||||
ref_entity: light.living_room
|
||||
off_duration: 00:30:00
|
||||
states:
|
||||
- time: sunrise
|
||||
@@ -76,7 +77,6 @@ living_room_button:
|
||||
class: Button
|
||||
app: living_room
|
||||
button: Living Room Button
|
||||
ref_entity: light.living_room
|
||||
|
||||
living_room_motion:
|
||||
module: motion
|
||||
|
||||
Reference in New Issue
Block a user