diff --git a/homeassistant/components/modbus/__init__.py b/homeassistant/components/modbus/__init__.py index 4c4a1390887..ed797891502 100644 --- a/homeassistant/components/modbus/__init__.py +++ b/homeassistant/components/modbus/__init__.py @@ -283,7 +283,9 @@ MODBUS_SCHEMA = vol.Schema( vol.Optional(CONF_BINARY_SENSORS): vol.All( cv.ensure_list, [BINARY_SENSOR_SCHEMA] ), - vol.Optional(CONF_CLIMATES): vol.All(cv.ensure_list, [CLIMATE_SCHEMA]), + vol.Optional(CONF_CLIMATES): vol.All( + cv.ensure_list, [vol.All(CLIMATE_SCHEMA, sensor_schema_validator)] + ), vol.Optional(CONF_COVERS): vol.All(cv.ensure_list, [COVERS_SCHEMA]), vol.Optional(CONF_LIGHTS): vol.All(cv.ensure_list, [LIGHT_SCHEMA]), vol.Optional(CONF_SENSORS): vol.All( diff --git a/homeassistant/components/modbus/climate.py b/homeassistant/components/modbus/climate.py index a178f6f0f84..5c99ac86d6c 100644 --- a/homeassistant/components/modbus/climate.py +++ b/homeassistant/components/modbus/climate.py @@ -40,8 +40,6 @@ from .const import ( CONF_SWAP_WORD, CONF_SWAP_WORD_BYTE, CONF_TARGET_TEMP, - DATA_TYPE_CUSTOM, - DEFAULT_STRUCT_FORMAT, MODBUS_DOMAIN, ) from .modbus import ModbusHub @@ -63,37 +61,6 @@ async def async_setup_platform( entities = [] for entity in discovery_info[CONF_CLIMATES]: hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]] - count = entity[CONF_COUNT] - data_type = entity[CONF_DATA_TYPE] - name = entity[CONF_NAME] - structure = entity[CONF_STRUCTURE] - - if data_type != DATA_TYPE_CUSTOM: - try: - structure = f">{DEFAULT_STRUCT_FORMAT[data_type][count]}" - except KeyError: - _LOGGER.error( - "Climate %s: Unable to find a data type matching count value %s, try a custom type", - name, - count, - ) - continue - - try: - size = struct.calcsize(structure) - except struct.error as err: - _LOGGER.error("Error in sensor %s structure: %s", name, err) - continue - - if count * 2 != size: - _LOGGER.error( - "Structure size (%d bytes) mismatch registers count (%d words)", - size, - count, - ) - continue - - entity[CONF_STRUCTURE] = structure entities.append(ModbusThermostat(hub, entity)) async_add_entities(entities)