formatting

This commit is contained in:
John Lancaster
2024-05-07 23:37:34 -05:00
parent a38341484d
commit 8eb9e84b9d
4 changed files with 50 additions and 43 deletions

View File

@@ -1,11 +1,14 @@
import logging
from enum import Enum
from typing import Literal, Optional
from logging import Logger
from typing import TYPE_CHECKING, Literal, Optional
from appdaemon.plugins.hass.hassapi import Hass
from appdaemon.plugins.mqtt.mqttapi import Mqtt
from pydantic import BaseModel, Field, TypeAdapter, field_validator
from room_control.console import setup_component_logging
from room_control import console
if TYPE_CHECKING:
from room_control import RoomController
class Side(int, Enum):
@@ -62,19 +65,21 @@ Callbacks = dict[str, dict[str, CallbackEntry]]
class AqaraCube(Hass, Mqtt):
app: 'RoomController'
logger: Logger
def initialize(self):
setup_component_logging(self)
self.logger.setLevel(self.args.get('rich', logging.INFO))
self.app: 'RoomController' = self.get_app(self.args['app'])
self.logger = console.load_rich_config(self.app.name, type(self).__name__, level='DEBUG')
topic = f'zigbee2mqtt/{self.args["cube"]}'
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]{topic}[/]')
self.app = self.get_app(self.args['app'])
self.log(f'Connected to AD app: [room]{self.app.name}[/]')
self.log(self.callbacks())
# self.log(f'Number of callbacks: {len(self.callbacks())}')
# for handle, cb in self.callbacks().items():
# self.log(repr(cb))
def terminate(self):
self.log('[bold red]Terminating[/]', level='DEBUG')