expert import mode

This commit is contained in:
John Lancaster
2024-05-02 22:49:46 -05:00
parent aedee1ac12
commit a38341484d
10 changed files with 21 additions and 26 deletions

View File

@@ -1,16 +1,11 @@
import logging
import sys
from enum import Enum
from pathlib import Path
from typing import Literal, Optional
from appdaemon.plugins.hass.hassapi import Hass
from appdaemon.plugins.mqtt.mqttapi import Mqtt
from pydantic import BaseModel, Field, TypeAdapter, field_validator
rc_path = (Path(__file__).resolve().parents[1] / 'room_control').as_posix()
sys.path.insert(0, rc_path)
from console import console, setup_component_logging
from room_control.console import setup_component_logging
class Side(int, Enum):
@@ -20,13 +15,10 @@ class Side(int, Enum):
front = 3
left = 4
bottom = 5
Actions = Literal[
'', 'wakeup',
'slide', 'shake',
'rotate_left', 'rotate_right',
'flip180', 'flip90'
'', 'wakeup', 'slide', 'shake', 'rotate_left', 'rotate_right', 'flip180', 'flip90'
]
@@ -104,9 +96,9 @@ class AqaraCube(Hass, Mqtt):
else:
self.log(
f'{event_name} on [topic]{data.topic}[/], Action: "[yellow]{str(action)}[/]"',
level='DEBUG'
level='DEBUG',
)
if (arg := self.args.get(action, False)):
if arg := self.args.get(action, False):
self.action_handler(action=action, description=arg)
elif handler := getattr(self, f'handle_{action}', None):
handler(data.payload)

View File

@@ -35,7 +35,7 @@ bathroom:
color_temp: 250
bathroom_button:
module: button
module: room_control
class: Button
dependencies:
- bathroom
@@ -45,7 +45,7 @@ bathroom_button:
ref_entity: light.bathroom
bathroom_motion:
module: motion
module: room_control
class: Motion
dependencies:
- bathroom

View File

@@ -77,7 +77,7 @@ bedroom:
sleep: input_boolean.sleeping
bedroom_buttons:
module: button
module: room_control
class: Button
dependencies:
- bedroom
@@ -89,7 +89,7 @@ bedroom_buttons:
- Bedroom Button 2
bedroom_motion:
module: motion
module: room_control
class: Motion
dependencies:
- bedroom

View File

@@ -28,7 +28,7 @@ closet:
color_temp: 400
closet_motion:
module: motion
module: room_control
class: Motion
dependencies:
- closet

View File

@@ -40,7 +40,7 @@ kitchen:
brightness: 25
kitchen_button:
module: button
module: room_control
class: Button
dependencies:
- kitchen
@@ -50,7 +50,7 @@ kitchen_button:
ref_entity: light.kitchen
kitchen_motion:
module: motion
module: room_control
class: Motion
dependencies:
- kitchen

View File

@@ -28,7 +28,7 @@ laundry:
color_temp: 400
laundry_motion:
module: motion
module: room_control
class: Motion
dependencies:
- laundry

View File

@@ -69,7 +69,7 @@ living_room:
brightness: 25
front_door:
module: door
module: room_control
class: Door
dependencies:
- living_room
@@ -78,7 +78,7 @@ front_door:
door: binary_sensor.front_contact
living_room_button:
module: button
module: room_control
class: Button
dependencies:
- living_room
@@ -88,7 +88,7 @@ living_room_button:
ref_entity: light.living_room
living_room_motion:
module: motion
module: room_control
class: Motion
dependencies:
- living_room