fix HA 2025.1 compatibility; cleanup

This commit is contained in:
d.dmitriev
2025-02-16 14:17:34 +05:00
parent 40ae6041ae
commit 3856088e79
9 changed files with 47 additions and 42 deletions

View File

@@ -12,16 +12,15 @@ from bs4 import BeautifulSoup
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS, PERCENTAGE, LIGHT_LUX
from homeassistant.const import PERCENTAGE, LIGHT_LUX, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from .config_parser import parse_config, DS2413, MCP230, MCP230_OUT, MCP230_IN, PCA9685
from .config_parser import parse_config, DS2413, MCP230, PCA9685
from .const import (
TEMP,
HUM,
PRESS,
LUX,
PATT_SPLIT,
DOMAIN,
CONF_HTTP,
EVENT_BINARY_SENSOR,
@@ -29,7 +28,6 @@ from .const import (
CONF_FORCE_D,
CONF_DEF_RESPONSE,
PATT_FW,
CONF_FORCE_I2C_SCAN,
REMOVE_CONFIG,
)
from .entities import set_events_off, BaseMegaEntity, MegaOutPort, safe_int, safe_float
@@ -42,7 +40,7 @@ HUM_PATT = re.compile(r"hum:([01234567890\.]+)")
PRESS_PATT = re.compile(r"press:([01234567890\.]+)")
LUX_PATT = re.compile(r"lux:([01234567890\.]+)")
PATTERNS = {TEMP: TEMP_PATT, HUM: HUM_PATT, PRESS: PRESS_PATT, LUX: LUX_PATT}
UNITS = {TEMP: TEMP_CELSIUS, HUM: PERCENTAGE, PRESS: "mmHg", LUX: LIGHT_LUX}
UNITS = {TEMP: UnitOfTemperature.CELSIUS, HUM: PERCENTAGE, PRESS: "mmHg", LUX: LIGHT_LUX}
CLASSES = {
TEMP: SensorDeviceClass.TEMPERATURE,
HUM: SensorDeviceClass.HUMIDITY,