Use HassKey in greeneye_monitor (#144878)

This commit is contained in:
epenet 2025-05-14 14:30:45 +02:00 committed by GitHub
parent fb9be3da79
commit 10dd11f257
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,14 @@
"""Shared constants for the greeneye_monitor integration."""
from __future__ import annotations
from typing import TYPE_CHECKING
from homeassistant.util.hass_dict import HassKey
if TYPE_CHECKING:
from greeneye import Monitors
CONF_CHANNELS = "channels"
CONF_COUNTED_QUANTITY = "counted_quantity"
CONF_COUNTED_QUANTITY_PER_PULSE = "counted_quantity_per_pulse"
@ -13,8 +22,8 @@ CONF_TEMPERATURE_SENSORS = "temperature_sensors"
CONF_TIME_UNIT = "time_unit"
CONF_VOLTAGE_SENSORS = "voltage"
DATA_GREENEYE_MONITOR = "greeneye_monitor"
DOMAIN = "greeneye_monitor"
DATA_GREENEYE_MONITOR: HassKey[Monitors] = HassKey(DOMAIN)
SENSOR_TYPE_CURRENT = "current_sensor"
SENSOR_TYPE_PULSE_COUNTER = "pulse_counter"

View File

@ -109,7 +109,7 @@ async def async_setup_platform(
if len(monitor_configs) == 0:
monitors.remove_listener(on_new_monitor)
monitors: greeneye.Monitors = hass.data[DATA_GREENEYE_MONITOR]
monitors = hass.data[DATA_GREENEYE_MONITOR]
monitors.add_listener(on_new_monitor)
for monitor in monitors.monitors.values():
on_new_monitor(monitor)