mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Make static modbus entity values classvar defaults (#136488)
This commit is contained in:
parent
b633a0424a
commit
b79221e666
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user