mirror of
https://github.com/home-assistant/core.git
synced 2026-08-28 02:24:46 -05:00
Remove unused hass argument in modbus
This commit is contained in:
@@ -52,7 +52,7 @@ async def async_setup_platform(
|
||||
slave_count = entry.get(CONF_SLAVE_COUNT, None) or entry.get(
|
||||
CONF_VIRTUAL_COUNT, 0
|
||||
)
|
||||
sensor = ModbusBinarySensor(hass, hub, entry, slave_count)
|
||||
sensor = ModbusBinarySensor(hub, entry, slave_count)
|
||||
if slave_count > 0:
|
||||
sensors.extend(await sensor.async_setup_slaves(hass, slave_count, entry))
|
||||
sensors.append(sensor)
|
||||
@@ -64,7 +64,6 @@ class ModbusBinarySensor(ModbusBaseEntity, RestoreEntity, BinarySensorEntity):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
hub: ModbusHub,
|
||||
entry: dict[str, Any],
|
||||
slave_count: int,
|
||||
@@ -73,7 +72,7 @@ class ModbusBinarySensor(ModbusBaseEntity, RestoreEntity, BinarySensorEntity):
|
||||
self._count = slave_count + 1
|
||||
self._coordinator: DataUpdateCoordinator[list[int] | None] | None = None
|
||||
self._result: list[int] = []
|
||||
super().__init__(hass, hub, entry)
|
||||
super().__init__(hub, entry)
|
||||
|
||||
async def async_setup_slaves(
|
||||
self, hass: HomeAssistant, slave_count: int, entry: dict[str, Any]
|
||||
|
||||
@@ -128,7 +128,7 @@ async def async_setup_platform(
|
||||
if discovery_info is None or not (climates := discovery_info[CONF_CLIMATES]):
|
||||
return
|
||||
hub = get_hub(hass, discovery_info[CONF_NAME])
|
||||
async_add_entities(ModbusThermostat(hass, hub, config) for config in climates)
|
||||
async_add_entities(ModbusThermostat(hub, config) for config in climates)
|
||||
|
||||
|
||||
class ModbusThermostat(ModbusStructEntity, RestoreEntity, ClimateEntity):
|
||||
@@ -142,12 +142,11 @@ class ModbusThermostat(ModbusStructEntity, RestoreEntity, ClimateEntity):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
hub: ModbusHub,
|
||||
config: dict[str, Any],
|
||||
) -> None:
|
||||
"""Initialize the modbus thermostat."""
|
||||
super().__init__(hass, hub, config)
|
||||
super().__init__(hub, config)
|
||||
self._target_temperature_register = config[CONF_TARGET_TEMP]
|
||||
self._target_temperature_write_registers = config[
|
||||
CONF_TARGET_TEMP_WRITE_REGISTERS
|
||||
|
||||
@@ -39,7 +39,7 @@ async def async_setup_platform(
|
||||
if discovery_info is None or not (covers := discovery_info[CONF_COVERS]):
|
||||
return
|
||||
hub = get_hub(hass, discovery_info[CONF_NAME])
|
||||
async_add_entities(ModbusCover(hass, hub, config) for config in covers)
|
||||
async_add_entities(ModbusCover(hub, config) for config in covers)
|
||||
|
||||
|
||||
class ModbusCover(ModbusBaseEntity, CoverEntity, RestoreEntity):
|
||||
@@ -49,12 +49,11 @@ class ModbusCover(ModbusBaseEntity, CoverEntity, RestoreEntity):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
hub: ModbusHub,
|
||||
config: dict[str, Any],
|
||||
) -> None:
|
||||
"""Initialize the modbus cover."""
|
||||
super().__init__(hass, hub, config)
|
||||
super().__init__(hub, config)
|
||||
self._state_closed = config[CONF_STATE_CLOSED]
|
||||
self._state_closing = config[CONF_STATE_CLOSING]
|
||||
self._state_open = config[CONF_STATE_OPEN]
|
||||
|
||||
@@ -25,7 +25,7 @@ from homeassistant.const import (
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import Entity, ToggleEntity
|
||||
from homeassistant.helpers.event import async_call_later
|
||||
@@ -76,9 +76,7 @@ class ModbusBaseEntity(Entity):
|
||||
_attr_available = True
|
||||
_attr_unit_of_measurement = None
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, hub: ModbusHub, entry: dict[str, Any]
|
||||
) -> None:
|
||||
def __init__(self, hub: ModbusHub, entry: dict[str, Any]) -> None:
|
||||
"""Initialize the Modbus binary sensor."""
|
||||
|
||||
self._hub = hub
|
||||
@@ -157,9 +155,9 @@ class ModbusBaseEntity(Entity):
|
||||
class ModbusStructEntity(ModbusBaseEntity, RestoreEntity):
|
||||
"""Base class representing a sensor/climate."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, hub: ModbusHub, config: dict) -> None:
|
||||
def __init__(self, hub: ModbusHub, config: dict) -> None:
|
||||
"""Initialize the switch."""
|
||||
super().__init__(hass, hub, config)
|
||||
super().__init__(hub, config)
|
||||
self._swap = config[CONF_SWAP]
|
||||
self._data_type = config[CONF_DATA_TYPE]
|
||||
self._structure: str = config[CONF_STRUCTURE]
|
||||
@@ -264,10 +262,10 @@ class ModbusStructEntity(ModbusBaseEntity, RestoreEntity):
|
||||
class ModbusToggleEntity(ModbusBaseEntity, ToggleEntity, RestoreEntity):
|
||||
"""Base class representing a Modbus switch."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, hub: ModbusHub, config: dict) -> None:
|
||||
def __init__(self, hub: ModbusHub, config: dict) -> None:
|
||||
"""Initialize the switch."""
|
||||
config[CONF_INPUT_TYPE] = ""
|
||||
super().__init__(hass, hub, config)
|
||||
super().__init__(hub, config)
|
||||
self._attr_is_on = False
|
||||
convert = {
|
||||
CALL_TYPE_REGISTER_HOLDING: (
|
||||
|
||||
@@ -28,17 +28,15 @@ async def async_setup_platform(
|
||||
if discovery_info is None or not (fans := discovery_info[CONF_FANS]):
|
||||
return
|
||||
hub = get_hub(hass, discovery_info[CONF_NAME])
|
||||
async_add_entities(ModbusFan(hass, hub, config) for config in fans)
|
||||
async_add_entities(ModbusFan(hub, config) for config in fans)
|
||||
|
||||
|
||||
class ModbusFan(ModbusToggleEntity, FanEntity):
|
||||
"""Class representing a Modbus fan."""
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, hub: ModbusHub, config: dict[str, Any]
|
||||
) -> None:
|
||||
def __init__(self, hub: ModbusHub, config: dict[str, Any]) -> None:
|
||||
"""Initialize the fan."""
|
||||
super().__init__(hass, hub, config)
|
||||
super().__init__(hub, config)
|
||||
if self.command_on is not None and self._command_off is not None:
|
||||
self._attr_supported_features |= (
|
||||
FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
|
||||
|
||||
@@ -46,17 +46,15 @@ async def async_setup_platform(
|
||||
if discovery_info is None or not (lights := discovery_info[CONF_LIGHTS]):
|
||||
return
|
||||
hub = get_hub(hass, discovery_info[CONF_NAME])
|
||||
async_add_entities(ModbusLight(hass, hub, config) for config in lights)
|
||||
async_add_entities(ModbusLight(hub, config) for config in lights)
|
||||
|
||||
|
||||
class ModbusLight(ModbusToggleEntity, LightEntity):
|
||||
"""Class representing a Modbus light."""
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, hub: ModbusHub, config: dict[str, Any]
|
||||
) -> None:
|
||||
def __init__(self, hub: ModbusHub, config: dict[str, Any]) -> None:
|
||||
"""Initialize the Modbus light entity."""
|
||||
super().__init__(hass, hub, config)
|
||||
super().__init__(hub, config)
|
||||
self._brightness_address: int | None = config.get(CONF_BRIGHTNESS_REGISTER)
|
||||
self._color_temp_address: int | None = config.get(CONF_COLOR_TEMP_REGISTER)
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ async def async_setup_platform(
|
||||
slave_count = entry.get(CONF_SLAVE_COUNT, None) or entry.get(
|
||||
CONF_VIRTUAL_COUNT, 0
|
||||
)
|
||||
sensor = ModbusRegisterSensor(hass, hub, entry, slave_count)
|
||||
sensor = ModbusRegisterSensor(hub, entry, slave_count)
|
||||
if slave_count > 0:
|
||||
sensors.extend(await sensor.async_setup_slaves(hass, slave_count, entry))
|
||||
sensors.append(sensor)
|
||||
@@ -61,13 +61,12 @@ class ModbusRegisterSensor(ModbusStructEntity, RestoreSensor, SensorEntity):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
hub: ModbusHub,
|
||||
entry: dict[str, Any],
|
||||
slave_count: int,
|
||||
) -> None:
|
||||
"""Initialize the modbus register sensor."""
|
||||
super().__init__(hass, hub, entry)
|
||||
super().__init__(hub, entry)
|
||||
if slave_count:
|
||||
self._count = self._count * (slave_count + 1)
|
||||
self._coordinator: DataUpdateCoordinator[list[float | None] | None] | None = (
|
||||
|
||||
@@ -26,7 +26,7 @@ async def async_setup_platform(
|
||||
if discovery_info is None or not (switches := discovery_info[CONF_SWITCHES]):
|
||||
return
|
||||
hub = get_hub(hass, discovery_info[CONF_NAME])
|
||||
async_add_entities(ModbusSwitch(hass, hub, config) for config in switches)
|
||||
async_add_entities(ModbusSwitch(hub, config) for config in switches)
|
||||
|
||||
|
||||
class ModbusSwitch(ModbusToggleEntity, SwitchEntity):
|
||||
|
||||
Reference in New Issue
Block a user