diff --git a/homeassistant/components/modbus/binary_sensor.py b/homeassistant/components/modbus/binary_sensor.py index 979888d0a198..d04938c929ad 100644 --- a/homeassistant/components/modbus/binary_sensor.py +++ b/homeassistant/components/modbus/binary_sensor.py @@ -35,7 +35,6 @@ from .const import ( DEFAULT_SCAN_INTERVAL, MODBUS_DOMAIN, ) -from .modbus import ModbusHub _LOGGER = logging.getLogger(__name__) @@ -84,14 +83,12 @@ async def async_setup_platform( CONF_NAME: "no name", CONF_BINARY_SENSORS: config[CONF_INPUTS], } - config = None for entry in discovery_info[CONF_BINARY_SENSORS]: if CONF_HUB in entry: - # from old config! - hub: ModbusHub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]] + hub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]] else: - hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]] + hub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]] if CONF_SCAN_INTERVAL not in entry: entry[CONF_SCAN_INTERVAL] = DEFAULT_SCAN_INTERVAL sensors.append( diff --git a/homeassistant/components/modbus/climate.py b/homeassistant/components/modbus/climate.py index d98cda3ed437..cc8f74577c78 100644 --- a/homeassistant/components/modbus/climate.py +++ b/homeassistant/components/modbus/climate.py @@ -242,7 +242,7 @@ class ModbusThermostat(ClimateEntity): ) if result is None: self._available = False - return + return -1 byte_string = b"".join( [x.to_bytes(2, byteorder="big") for x in result.registers] @@ -255,11 +255,11 @@ class ModbusThermostat(ClimateEntity): ) return -1 - val = val[0] + val2 = val[0] register_value = format( - (self._scale * val) + self._offset, f".{self._precision}f" + (self._scale * val2) + self._offset, f".{self._precision}f" ) - register_value = float(register_value) + register_value2 = float(register_value) self._available = True - return register_value + return register_value2 diff --git a/homeassistant/components/modbus/sensor.py b/homeassistant/components/modbus/sensor.py index c1a33c41f6d3..91f80864f73b 100644 --- a/homeassistant/components/modbus/sensor.py +++ b/homeassistant/components/modbus/sensor.py @@ -58,7 +58,6 @@ from .const import ( DEFAULT_STRUCT_FORMAT, MODBUS_DOMAIN, ) -from .modbus import ModbusHub _LOGGER = logging.getLogger(__name__) @@ -120,7 +119,6 @@ async def async_setup_platform( entry[CONF_INPUT_TYPE] = entry[CONF_REGISTER_TYPE] del entry[CONF_REGISTER] del entry[CONF_REGISTER_TYPE] - config = None for entry in discovery_info[CONF_SENSORS]: if entry[CONF_DATA_TYPE] == DATA_TYPE_STRING: @@ -175,9 +173,9 @@ async def async_setup_platform( continue if CONF_HUB in entry: # from old config! - hub: ModbusHub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]] + hub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]] else: - hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]] + hub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]] if CONF_SCAN_INTERVAL not in entry: entry[CONF_SCAN_INTERVAL] = DEFAULT_SCAN_INTERVAL sensors.append( diff --git a/mypy.ini b/mypy.ini index 30fe27177a6c..42e5c0101f2c 100644 --- a/mypy.ini +++ b/mypy.ini @@ -993,9 +993,6 @@ ignore_errors = true [mypy-homeassistant.components.mobile_app.*] ignore_errors = true -[mypy-homeassistant.components.modbus.*] -ignore_errors = true - [mypy-homeassistant.components.motion_blinds.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 05763fb65179..a840723b20e5 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -134,7 +134,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.metoffice.*", "homeassistant.components.minecraft_server.*", "homeassistant.components.mobile_app.*", - "homeassistant.components.modbus.*", "homeassistant.components.motion_blinds.*", "homeassistant.components.motioneye.*", "homeassistant.components.mqtt.*",