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