1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Rename modbus base entities (#152595)

This commit is contained in:
epenet
2025-09-19 09:17:31 +02:00
committed by GitHub
parent 10f2955d34
commit c125554817
9 changed files with 18 additions and 18 deletions

View File

@@ -29,7 +29,7 @@ from .const import (
CONF_SLAVE_COUNT,
CONF_VIRTUAL_COUNT,
)
from .entity import BasePlatform
from .entity import ModbusBaseEntity
from .modbus import ModbusHub
PARALLEL_UPDATES = 1
@@ -59,7 +59,7 @@ async def async_setup_platform(
async_add_entities(sensors)
class ModbusBinarySensor(BasePlatform, RestoreEntity, BinarySensorEntity):
class ModbusBinarySensor(ModbusBaseEntity, RestoreEntity, BinarySensorEntity):
"""Modbus binary sensor."""
def __init__(

View File

@@ -101,7 +101,7 @@ from .const import (
CONF_WRITE_REGISTERS,
DataType,
)
from .entity import BaseStructPlatform
from .entity import ModbusStructEntity
from .modbus import ModbusHub
PARALLEL_UPDATES = 1
@@ -131,7 +131,7 @@ async def async_setup_platform(
async_add_entities(ModbusThermostat(hass, hub, config) for config in climates)
class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
class ModbusThermostat(ModbusStructEntity, RestoreEntity, ClimateEntity):
"""Representation of a Modbus Thermostat."""
_attr_supported_features = (

View File

@@ -23,7 +23,7 @@ from .const import (
CONF_STATUS_REGISTER,
CONF_STATUS_REGISTER_TYPE,
)
from .entity import BasePlatform
from .entity import ModbusBaseEntity
from .modbus import ModbusHub
PARALLEL_UPDATES = 1
@@ -42,7 +42,7 @@ async def async_setup_platform(
async_add_entities(ModbusCover(hass, hub, config) for config in covers)
class ModbusCover(BasePlatform, CoverEntity, RestoreEntity):
class ModbusCover(ModbusBaseEntity, CoverEntity, RestoreEntity):
"""Representation of a Modbus cover."""
_attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE

View File

@@ -68,7 +68,7 @@ from .const import (
from .modbus import ModbusHub
class BasePlatform(Entity):
class ModbusBaseEntity(Entity):
"""Base for readonly platforms."""
_value: str | None = None
@@ -154,7 +154,7 @@ class BasePlatform(Entity):
)
class BaseStructPlatform(BasePlatform, RestoreEntity):
class ModbusStructEntity(ModbusBaseEntity, RestoreEntity):
"""Base class representing a sensor/climate."""
def __init__(self, hass: HomeAssistant, hub: ModbusHub, config: dict) -> None:
@@ -261,7 +261,7 @@ class BaseStructPlatform(BasePlatform, RestoreEntity):
return self.__process_raw_value(val[0])
class BaseSwitch(BasePlatform, ToggleEntity, RestoreEntity):
class ModbusToggleEntity(ModbusBaseEntity, ToggleEntity, RestoreEntity):
"""Base class representing a Modbus switch."""
def __init__(self, hass: HomeAssistant, hub: ModbusHub, config: dict) -> None:

View File

@@ -12,7 +12,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import get_hub
from .const import CONF_FANS
from .entity import BaseSwitch
from .entity import ModbusToggleEntity
from .modbus import ModbusHub
PARALLEL_UPDATES = 1
@@ -31,7 +31,7 @@ async def async_setup_platform(
async_add_entities(ModbusFan(hass, hub, config) for config in fans)
class ModbusFan(BaseSwitch, FanEntity):
class ModbusFan(ModbusToggleEntity, FanEntity):
"""Class representing a Modbus fan."""
def __init__(

View File

@@ -30,7 +30,7 @@ from .const import (
LIGHT_MODBUS_SCALE_MAX,
LIGHT_MODBUS_SCALE_MIN,
)
from .entity import BaseSwitch
from .entity import ModbusToggleEntity
from .modbus import ModbusHub
PARALLEL_UPDATES = 1
@@ -49,7 +49,7 @@ async def async_setup_platform(
async_add_entities(ModbusLight(hass, hub, config) for config in lights)
class ModbusLight(BaseSwitch, LightEntity):
class ModbusLight(ModbusToggleEntity, LightEntity):
"""Class representing a Modbus light."""
def __init__(

View File

@@ -26,7 +26,7 @@ from homeassistant.helpers.update_coordinator import (
from . import get_hub
from .const import _LOGGER, CONF_SLAVE_COUNT, CONF_VIRTUAL_COUNT
from .entity import BaseStructPlatform
from .entity import ModbusStructEntity
from .modbus import ModbusHub
PARALLEL_UPDATES = 1
@@ -56,7 +56,7 @@ async def async_setup_platform(
async_add_entities(sensors)
class ModbusRegisterSensor(BaseStructPlatform, RestoreSensor, SensorEntity):
class ModbusRegisterSensor(ModbusStructEntity, RestoreSensor, SensorEntity):
"""Modbus register sensor."""
def __init__(

View File

@@ -11,7 +11,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import get_hub
from .entity import BaseSwitch
from .entity import ModbusToggleEntity
PARALLEL_UPDATES = 1
@@ -29,7 +29,7 @@ async def async_setup_platform(
async_add_entities(ModbusSwitch(hass, hub, config) for config in switches)
class ModbusSwitch(BaseSwitch, SwitchEntity):
class ModbusSwitch(ModbusToggleEntity, SwitchEntity):
"""Base class representing a Modbus switch."""
async def async_turn_on(self, **kwargs: Any) -> None:

View File

@@ -8,7 +8,7 @@ This file is responsible for testing:
const.py
modbus.py
validators.py
baseplatform.py (only BasePlatform)
entity.py (only ModbusBaseEntity)
It uses binary_sensors/sensors to do black box testing of the read calls.
"""