diff --git a/homeassistant/components/zha/sensor.py b/homeassistant/components/zha/sensor.py index a18d6bfa9dd..6f06b381844 100644 --- a/homeassistant/components/zha/sensor.py +++ b/homeassistant/components/zha/sensor.py @@ -27,6 +27,7 @@ from homeassistant.util.temperature import fahrenheit_to_celsius from .core import discovery from .core.const import ( + CHANNEL_ANALOG_INPUT, CHANNEL_ELECTRICAL_MEASUREMENT, CHANNEL_HUMIDITY, CHANNEL_ILLUMINANCE, @@ -153,6 +154,13 @@ class Sensor(ZhaEntity): return round(float(value * self._multiplier) / self._divisor) +@STRICT_MATCH(channel_names=CHANNEL_ANALOG_INPUT, manufacturers="Digi") +class AnalogInput(Sensor): + """Sensor that displays analog input values.""" + + SENSOR_ATTR = "present_value" + + @STRICT_MATCH(channel_names=CHANNEL_POWER_CONFIGURATION) class Battery(Sensor): """Battery sensor of power configuration cluster.""" diff --git a/tests/components/zha/zha_devices_list.py b/tests/components/zha/zha_devices_list.py index e33cb48778c..a6287592395 100644 --- a/tests/components/zha/zha_devices_list.py +++ b/tests/components/zha/zha_devices_list.py @@ -3464,4 +3464,248 @@ DEVICES = [ "model": "unk_model", "node_descriptor": b"\x01@\x8e\x10\x11RR\x00\x00\x00R\x00\x00", }, + { + "device_no": 98, + "endpoints": { + 208: { + "endpoint_id": 208, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006, 0x000C], + "out_clusters": [], + }, + 209: { + "endpoint_id": 209, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006, 0x000C], + "out_clusters": [], + }, + 210: { + "endpoint_id": 210, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006, 0x000C], + "out_clusters": [], + }, + 211: { + "endpoint_id": 211, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006, 0x000C], + "out_clusters": [], + }, + 212: { + "endpoint_id": 212, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006], + "out_clusters": [], + }, + 213: { + "endpoint_id": 213, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006], + "out_clusters": [], + }, + 214: { + "endpoint_id": 214, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006], + "out_clusters": [], + }, + 215: { + "endpoint_id": 215, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006, 0x000C], + "out_clusters": [], + }, + 216: { + "endpoint_id": 216, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006], + "out_clusters": [], + }, + 217: { + "endpoint_id": 217, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006], + "out_clusters": [], + }, + 218: { + "endpoint_id": 218, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006, 0x000D], + "out_clusters": [], + }, + 219: { + "endpoint_id": 219, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006, 0x000D], + "out_clusters": [], + }, + 220: { + "endpoint_id": 220, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006], + "out_clusters": [], + }, + 221: { + "endpoint_id": 221, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006], + "out_clusters": [], + }, + 222: { + "endpoint_id": 222, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0006], + "out_clusters": [], + }, + 232: { + "endpoint_id": 232, + "profile_id": 49413, + "device_type": 0x0001, + "in_clusters": [0x0011, 0x0092], + "out_clusters": [0x0008, 0x0011], + }, + }, + "entities": [ + "switch.digi_xbee3_77665544_on_off", + "switch.digi_xbee3_77665544_on_off_2", + "switch.digi_xbee3_77665544_on_off_3", + "switch.digi_xbee3_77665544_on_off_4", + "switch.digi_xbee3_77665544_on_off_5", + "switch.digi_xbee3_77665544_on_off_6", + "switch.digi_xbee3_77665544_on_off_7", + "switch.digi_xbee3_77665544_on_off_8", + "switch.digi_xbee3_77665544_on_off_9", + "switch.digi_xbee3_77665544_on_off_10", + "switch.digi_xbee3_77665544_on_off_11", + "switch.digi_xbee3_77665544_on_off_12", + "switch.digi_xbee3_77665544_on_off_13", + "switch.digi_xbee3_77665544_on_off_14", + "switch.digi_xbee3_77665544_on_off_15", + "sensor.digi_xbee3_77665544_analog_input", + "sensor.digi_xbee3_77665544_analog_input_2", + "sensor.digi_xbee3_77665544_analog_input_3", + "sensor.digi_xbee3_77665544_analog_input_4", + ], + "entity_map": { + ("switch", "00:11:22:33:44:55:66:77-208-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off", + }, + ("switch", "00:11:22:33:44:55:66:77-209-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_2", + }, + ("switch", "00:11:22:33:44:55:66:77-210-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_3", + }, + ("switch", "00:11:22:33:44:55:66:77-211-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_4", + }, + ("switch", "00:11:22:33:44:55:66:77-212-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_5", + }, + ("switch", "00:11:22:33:44:55:66:77-213-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_6", + }, + ("switch", "00:11:22:33:44:55:66:77-214-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_7", + }, + ("switch", "00:11:22:33:44:55:66:77-215-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_8", + }, + ("switch", "00:11:22:33:44:55:66:77-216-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_9", + }, + ("switch", "00:11:22:33:44:55:66:77-217-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_10", + }, + ("switch", "00:11:22:33:44:55:66:77-218-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_11", + }, + ("switch", "00:11:22:33:44:55:66:77-219-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_12", + }, + ("switch", "00:11:22:33:44:55:66:77-220-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_13", + }, + ("switch", "00:11:22:33:44:55:66:77-221-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_14", + }, + ("switch", "00:11:22:33:44:55:66:77-222-6"): { + "channels": ["on_off"], + "entity_class": "Switch", + "entity_id": "switch.digi_xbee3_77665544_on_off_15", + }, + ("sensor", "00:11:22:33:44:55:66:77-208-12"): { + "channels": ["analog_input"], + "entity_class": "AnalogInput", + "entity_id": "sensor.digi_xbee3_77665544_analog_input", + }, + ("sensor", "00:11:22:33:44:55:66:77-209-12"): { + "channels": ["analog_input"], + "entity_class": "AnalogInput", + "entity_id": "sensor.digi_xbee3_77665544_analog_input_2", + }, + ("sensor", "00:11:22:33:44:55:66:77-210-12"): { + "channels": ["analog_input"], + "entity_class": "AnalogInput", + "entity_id": "sensor.digi_xbee3_77665544_analog_input_3", + }, + ("sensor", "00:11:22:33:44:55:66:77-211-12"): { + "channels": ["analog_input"], + "entity_class": "AnalogInput", + "entity_id": "sensor.digi_xbee3_77665544_analog_input_4", + }, + ("sensor", "00:11:22:33:44:55:66:77-215-12"): { + "channels": ["analog_input"], + "entity_class": "AnalogInput", + "entity_id": "sensor.digi_xbee3_77665544_analog_input_5", + }, + }, + "event_channels": ["232:0x0008"], + "manufacturer": "Digi", + "model": "XBee3", + "node_descriptor": b"\x01@\x8e\x1e\x10R\xff\x00\x00,\xff\x00\x00", + }, ]