diff --git a/homeassistant/components/modbus/binary_sensor.py b/homeassistant/components/modbus/binary_sensor.py index c230cfc5379e..bd11173bbd37 100644 --- a/homeassistant/components/modbus/binary_sensor.py +++ b/homeassistant/components/modbus/binary_sensor.py @@ -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] diff --git a/homeassistant/components/modbus/climate.py b/homeassistant/components/modbus/climate.py index a99a8839ba30..daf70c59348d 100644 --- a/homeassistant/components/modbus/climate.py +++ b/homeassistant/components/modbus/climate.py @@ -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 diff --git a/homeassistant/components/modbus/cover.py b/homeassistant/components/modbus/cover.py index 21d04d2ffc4b..9a356ad405e2 100644 --- a/homeassistant/components/modbus/cover.py +++ b/homeassistant/components/modbus/cover.py @@ -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] diff --git a/homeassistant/components/modbus/entity.py b/homeassistant/components/modbus/entity.py index 5a25870512e1..45b8bd1c797c 100644 --- a/homeassistant/components/modbus/entity.py +++ b/homeassistant/components/modbus/entity.py @@ -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: ( diff --git a/homeassistant/components/modbus/fan.py b/homeassistant/components/modbus/fan.py index 3602fbc5879c..0f0eebc49afe 100644 --- a/homeassistant/components/modbus/fan.py +++ b/homeassistant/components/modbus/fan.py @@ -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 diff --git a/homeassistant/components/modbus/light.py b/homeassistant/components/modbus/light.py index 4c27ffb456b6..3e20a414349d 100644 --- a/homeassistant/components/modbus/light.py +++ b/homeassistant/components/modbus/light.py @@ -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) diff --git a/homeassistant/components/modbus/sensor.py b/homeassistant/components/modbus/sensor.py index 185d336cc6a9..cd04ba2552a1 100644 --- a/homeassistant/components/modbus/sensor.py +++ b/homeassistant/components/modbus/sensor.py @@ -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 = ( diff --git a/homeassistant/components/modbus/switch.py b/homeassistant/components/modbus/switch.py index 9fc3115901dd..98a60dcf4816 100644 --- a/homeassistant/components/modbus/switch.py +++ b/homeassistant/components/modbus/switch.py @@ -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):