From 5c08486ef3eeee46f655e2389356743c28a7229a Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 23 Nov 2025 12:09:57 +0000 Subject: [PATCH] Pass logfire native logging handler to aiomqtt --- haco/climate.py | 10 +++++----- haco/sb3.py | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/haco/climate.py b/haco/climate.py index 3a27c38..7e4a029 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -1,5 +1,5 @@ from dataclasses import dataclass -from typing import List, Optional, Literal +from typing import Literal from capabilities import Capability from control import Control @@ -18,10 +18,10 @@ class Climate(Control): humidity_min: float = 0 humidity_max: float = 100 precision: int = 1 - modes: Optional[List[str]] = None - preset_modes: Optional[List[str]] = None - fan_modes: Optional[List[str]] = None - swing_modes: Optional[List[str]] = None + modes: list[str] | None = None + preset_modes: list[str] | None = None + fan_modes: list[str] | None = None + swing_modes: list[str] | None = None def temperature_command(self, value): diff --git a/haco/sb3.py b/haco/sb3.py index 1fa7c5c..157fc8f 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -1,13 +1,17 @@ import asyncio +import logging from haco.button import Button from haco.client import ClientHaco from haco.climate import Climate from haco.constants import MQTT_HOST from haco.device import Device +from haco.obs import logger from haco.pulldown import Select from haco.switch import Switch +handler = logger.LogfireLoggingHandler() +logging.basicConfig(handlers=[handler], level=logging.DEBUG) async def main(): climate_a = Climate(name="Dev Climate A", fan_modes=['a', 'b', 'c']) @@ -19,7 +23,7 @@ async def main(): sel1 = Select(name="Dev Select 1", options=['a', 'b', 'c']) device = Device(name="Dev Device", controls=[climate_a, climate_b, b1, s1, sel1]) - client = ClientHaco(hostname=MQTT_HOST, device=device) + client = ClientHaco(hostname=MQTT_HOST, device=device, logger=logging.getLogger(__name__)) await client.start()