Make static modbus entity values classvar defaults (#136488)

This commit is contained in:
J. Nick Koston 2025-01-27 10:25:20 -10:00 committed by GitHub
parent b633a0424a
commit b79221e666
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,6 +74,11 @@ _LOGGER = logging.getLogger(__name__)
class BasePlatform(Entity):
"""Base for readonly platforms."""
_value: str | None = None
_attr_should_poll = False
_attr_available = True
_attr_unit_of_measurement = None
def __init__(
self, hass: HomeAssistant, hub: ModbusHub, entry: dict[str, Any]
) -> None:
@ -86,17 +91,13 @@ class BasePlatform(Entity):
self._slave = entry.get(CONF_DEVICE_ADDRESS, 1)
self._address = int(entry[CONF_ADDRESS])
self._input_type = entry[CONF_INPUT_TYPE]
self._value: str | None = None
self._scan_interval = int(entry[CONF_SCAN_INTERVAL])
self._cancel_timer: Callable[[], None] | None = None
self._cancel_call: Callable[[], None] | None = None
self._attr_unique_id = entry.get(CONF_UNIQUE_ID)
self._attr_name = entry[CONF_NAME]
self._attr_should_poll = False
self._attr_device_class = entry.get(CONF_DEVICE_CLASS)
self._attr_available = True
self._attr_unit_of_measurement = None
def get_optional_numeric_config(config_name: str) -> int | float | None:
if (val := entry.get(config_name)) is None: