Drop ZHA sensor for Analog/Multistate input clusters (#36696)

This commit is contained in:
Alexei Chetroi 2020-06-12 06:08:11 -04:00 committed by GitHub
parent 5a3e0c6b25
commit 5595ef0783
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 139 deletions

View File

@ -3,6 +3,8 @@ import asyncio
import logging import logging
from typing import Any, Dict, List, Optional, Tuple, Union from typing import Any, Dict, List, Optional, Tuple, Union
import zigpy.zcl.clusters.closures
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
@ -280,9 +282,10 @@ class ChannelPool:
# incorrectly. # incorrectly.
if ( if (
hasattr(cluster, "ep_attribute") hasattr(cluster, "ep_attribute")
and cluster_id == zigpy.zcl.clusters.closures.DoorLock.cluster_id
and cluster.ep_attribute == "multistate_input" and cluster.ep_attribute == "multistate_input"
): ):
channel_class = base.ZigbeeChannel channel_class = general.MultistateInput
# end of ugly hack # end of ugly hack
channel = channel_class(cluster, self) channel = channel_class(cluster, self)
if channel.name == const.CHANNEL_POWER_CONFIGURATION: if channel.name == const.CHANNEL_POWER_CONFIGURATION:

View File

@ -25,11 +25,9 @@ from homeassistant.util.temperature import fahrenheit_to_celsius
from .core import discovery from .core import discovery
from .core.const import ( from .core.const import (
CHANNEL_ANALOG_INPUT,
CHANNEL_ELECTRICAL_MEASUREMENT, CHANNEL_ELECTRICAL_MEASUREMENT,
CHANNEL_HUMIDITY, CHANNEL_HUMIDITY,
CHANNEL_ILLUMINANCE, CHANNEL_ILLUMINANCE,
CHANNEL_MULTISTATE_INPUT,
CHANNEL_POWER_CONFIGURATION, CHANNEL_POWER_CONFIGURATION,
CHANNEL_PRESSURE, CHANNEL_PRESSURE,
CHANNEL_SMARTENERGY_METERING, CHANNEL_SMARTENERGY_METERING,
@ -153,13 +151,6 @@ class Sensor(ZhaEntity):
return round(float(value * self._multiplier) / self._divisor) return round(float(value * self._multiplier) / self._divisor)
@STRICT_MATCH(channel_names=CHANNEL_ANALOG_INPUT)
class AnalogInput(Sensor):
"""Sensor that displays analog input values."""
SENSOR_ATTR = "present_value"
@STRICT_MATCH(channel_names=CHANNEL_POWER_CONFIGURATION) @STRICT_MATCH(channel_names=CHANNEL_POWER_CONFIGURATION)
class Battery(Sensor): class Battery(Sensor):
"""Battery sensor of power configuration cluster.""" """Battery sensor of power configuration cluster."""
@ -220,18 +211,6 @@ class ElectricalMeasurement(Sensor):
return round(value) return round(value)
@STRICT_MATCH(channel_names=CHANNEL_MULTISTATE_INPUT)
class Text(Sensor):
"""Sensor that displays string values."""
_device_class = None
_unit = None
def formatter(self, value) -> str:
"""Return string value."""
return value
@STRICT_MATCH(generic_ids=CHANNEL_ST_HUMIDITY_CLUSTER) @STRICT_MATCH(generic_ids=CHANNEL_ST_HUMIDITY_CLUSTER)
@STRICT_MATCH(channel_names=CHANNEL_HUMIDITY) @STRICT_MATCH(channel_names=CHANNEL_HUMIDITY)
class Humidity(Sensor): class Humidity(Sensor):

View File

@ -1372,8 +1372,6 @@ DEVICES = [
}, },
}, },
"entities": [ "entities": [
"sensor.lumi_lumi_plug_maus01_77665544_analog_input",
"sensor.lumi_lumi_plug_maus01_77665544_analog_input_2",
"sensor.lumi_lumi_plug_maus01_77665544_electrical_measurement", "sensor.lumi_lumi_plug_maus01_77665544_electrical_measurement",
"switch.lumi_lumi_plug_maus01_77665544_on_off", "switch.lumi_lumi_plug_maus01_77665544_on_off",
], ],
@ -1388,16 +1386,6 @@ DEVICES = [
"entity_class": "ElectricalMeasurement", "entity_class": "ElectricalMeasurement",
"entity_id": "sensor.lumi_lumi_plug_maus01_77665544_electrical_measurement", "entity_id": "sensor.lumi_lumi_plug_maus01_77665544_electrical_measurement",
}, },
("sensor", "00:11:22:33:44:55:66:77-2-12"): {
"channels": ["analog_input"],
"entity_class": "AnalogInput",
"entity_id": "sensor.lumi_lumi_plug_maus01_77665544_analog_input",
},
("sensor", "00:11:22:33:44:55:66:77-3-12"): {
"channels": ["analog_input"],
"entity_class": "AnalogInput",
"entity_id": "sensor.lumi_lumi_plug_maus01_77665544_analog_input_2",
},
}, },
"event_channels": ["1:0x0019"], "event_channels": ["1:0x0019"],
"manufacturer": "LUMI", "manufacturer": "LUMI",
@ -1426,7 +1414,6 @@ DEVICES = [
"entities": [ "entities": [
"light.lumi_lumi_relay_c2acn01_77665544_on_off", "light.lumi_lumi_relay_c2acn01_77665544_on_off",
"light.lumi_lumi_relay_c2acn01_77665544_on_off_2", "light.lumi_lumi_relay_c2acn01_77665544_on_off_2",
"sensor.lumi_lumi_relay_c2acn01_77665544_analog_input",
"sensor.lumi_lumi_relay_c2acn01_77665544_electrical_measurement", "sensor.lumi_lumi_relay_c2acn01_77665544_electrical_measurement",
], ],
"entity_map": { "entity_map": {
@ -1435,11 +1422,6 @@ DEVICES = [
"entity_class": "Light", "entity_class": "Light",
"entity_id": "light.lumi_lumi_relay_c2acn01_77665544_on_off", "entity_id": "light.lumi_lumi_relay_c2acn01_77665544_on_off",
}, },
("sensor", "00:11:22:33:44:55:66:77-1-12"): {
"channels": ["analog_input"],
"entity_class": "AnalogInput",
"entity_id": "sensor.lumi_lumi_relay_c2acn01_77665544_analog_input",
},
("sensor", "00:11:22:33:44:55:66:77-1-2820"): { ("sensor", "00:11:22:33:44:55:66:77-1-2820"): {
"channels": ["electrical_measurement"], "channels": ["electrical_measurement"],
"entity_class": "ElectricalMeasurement", "entity_class": "ElectricalMeasurement",
@ -1482,33 +1464,13 @@ DEVICES = [
"profile_id": 260, "profile_id": 260,
}, },
}, },
"entities": [ "entities": ["sensor.lumi_lumi_remote_b186acn01_77665544_power"],
"sensor.lumi_lumi_remote_b186acn01_77665544_multistate_input",
"sensor.lumi_lumi_remote_b186acn01_77665544_multistate_input_2",
"sensor.lumi_lumi_remote_b186acn01_77665544_multistate_input_3",
"sensor.lumi_lumi_remote_b186acn01_77665544_power",
],
"entity_map": { "entity_map": {
("sensor", "00:11:22:33:44:55:66:77-1-1"): { ("sensor", "00:11:22:33:44:55:66:77-1-1"): {
"channels": ["power"], "channels": ["power"],
"entity_class": "Battery", "entity_class": "Battery",
"entity_id": "sensor.lumi_lumi_remote_b186acn01_77665544_power", "entity_id": "sensor.lumi_lumi_remote_b186acn01_77665544_power",
}, },
("sensor", "00:11:22:33:44:55:66:77-1-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_remote_b186acn01_77665544_multistate_input_2",
},
("sensor", "00:11:22:33:44:55:66:77-2-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_remote_b186acn01_77665544_multistate_input_3",
},
("sensor", "00:11:22:33:44:55:66:77-3-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_remote_b186acn01_77665544_multistate_input",
},
}, },
"event_channels": ["1:0x0005", "1:0x0019", "2:0x0005", "3:0x0005"], "event_channels": ["1:0x0005", "1:0x0019", "2:0x0005", "3:0x0005"],
"manufacturer": "LUMI", "manufacturer": "LUMI",
@ -1541,33 +1503,13 @@ DEVICES = [
"profile_id": 260, "profile_id": 260,
}, },
}, },
"entities": [ "entities": ["sensor.lumi_lumi_remote_b286acn01_77665544_power"],
"sensor.lumi_lumi_remote_b286acn01_77665544_multistate_input",
"sensor.lumi_lumi_remote_b286acn01_77665544_multistate_input_2",
"sensor.lumi_lumi_remote_b286acn01_77665544_multistate_input_3",
"sensor.lumi_lumi_remote_b286acn01_77665544_power",
],
"entity_map": { "entity_map": {
("sensor", "00:11:22:33:44:55:66:77-1-1"): { ("sensor", "00:11:22:33:44:55:66:77-1-1"): {
"channels": ["power"], "channels": ["power"],
"entity_class": "Battery", "entity_class": "Battery",
"entity_id": "sensor.lumi_lumi_remote_b286acn01_77665544_power", "entity_id": "sensor.lumi_lumi_remote_b286acn01_77665544_power",
}, },
("sensor", "00:11:22:33:44:55:66:77-1-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_remote_b286acn01_77665544_multistate_input_3",
},
("sensor", "00:11:22:33:44:55:66:77-2-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_remote_b286acn01_77665544_multistate_input_2",
},
("sensor", "00:11:22:33:44:55:66:77-3-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_remote_b286acn01_77665544_multistate_input",
},
}, },
"event_channels": ["1:0x0005", "1:0x0019", "2:0x0005", "3:0x0005"], "event_channels": ["1:0x0005", "1:0x0019", "2:0x0005", "3:0x0005"],
"manufacturer": "LUMI", "manufacturer": "LUMI",
@ -1897,33 +1839,13 @@ DEVICES = [
"profile_id": 260, "profile_id": 260,
}, },
}, },
"entities": [ "entities": ["sensor.lumi_lumi_sensor_86sw1_77665544_power"],
"sensor.lumi_lumi_sensor_86sw1_77665544_multistate_input",
"sensor.lumi_lumi_sensor_86sw1_77665544_multistate_input_2",
"sensor.lumi_lumi_sensor_86sw1_77665544_multistate_input_3",
"sensor.lumi_lumi_sensor_86sw1_77665544_power",
],
"entity_map": { "entity_map": {
("sensor", "00:11:22:33:44:55:66:77-1-1"): { ("sensor", "00:11:22:33:44:55:66:77-1-1"): {
"channels": ["power"], "channels": ["power"],
"entity_class": "Battery", "entity_class": "Battery",
"entity_id": "sensor.lumi_lumi_sensor_86sw1_77665544_power", "entity_id": "sensor.lumi_lumi_sensor_86sw1_77665544_power",
}, },
("sensor", "00:11:22:33:44:55:66:77-1-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_sensor_86sw1_77665544_multistate_input_3",
},
("sensor", "00:11:22:33:44:55:66:77-2-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_sensor_86sw1_77665544_multistate_input_2",
},
("sensor", "00:11:22:33:44:55:66:77-3-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_sensor_86sw1_77665544_multistate_input",
},
}, },
"event_channels": ["1:0x0005", "1:0x0019", "2:0x0005", "3:0x0005"], "event_channels": ["1:0x0005", "1:0x0019", "2:0x0005", "3:0x0005"],
"manufacturer": "LUMI", "manufacturer": "LUMI",
@ -1956,27 +1878,13 @@ DEVICES = [
"profile_id": 260, "profile_id": 260,
}, },
}, },
"entities": [ "entities": ["sensor.lumi_lumi_sensor_cube_aqgl01_77665544_power"],
"sensor.lumi_lumi_sensor_cube_aqgl01_77665544_analog_input",
"sensor.lumi_lumi_sensor_cube_aqgl01_77665544_multistate_input",
"sensor.lumi_lumi_sensor_cube_aqgl01_77665544_power",
],
"entity_map": { "entity_map": {
("sensor", "00:11:22:33:44:55:66:77-1-1"): { ("sensor", "00:11:22:33:44:55:66:77-1-1"): {
"channels": ["power"], "channels": ["power"],
"entity_class": "Battery", "entity_class": "Battery",
"entity_id": "sensor.lumi_lumi_sensor_cube_aqgl01_77665544_power", "entity_id": "sensor.lumi_lumi_sensor_cube_aqgl01_77665544_power",
}, },
("sensor", "00:11:22:33:44:55:66:77-2-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_sensor_cube_aqgl01_77665544_multistate_input",
},
("sensor", "00:11:22:33:44:55:66:77-3-12"): {
"channels": ["analog_input"],
"entity_class": "AnalogInput",
"entity_id": "sensor.lumi_lumi_sensor_cube_aqgl01_77665544_analog_input",
},
}, },
"event_channels": ["1:0x0005", "1:0x0019", "2:0x0005", "3:0x0005"], "event_channels": ["1:0x0005", "1:0x0019", "2:0x0005", "3:0x0005"],
"manufacturer": "LUMI", "manufacturer": "LUMI",
@ -2161,8 +2069,6 @@ DEVICES = [
}, },
"entities": [ "entities": [
"binary_sensor.lumi_lumi_sensor_smoke_77665544_ias_zone", "binary_sensor.lumi_lumi_sensor_smoke_77665544_ias_zone",
"sensor.lumi_lumi_sensor_smoke_77665544_analog_input",
"sensor.lumi_lumi_sensor_smoke_77665544_multistate_input",
"sensor.lumi_lumi_sensor_smoke_77665544_power", "sensor.lumi_lumi_sensor_smoke_77665544_power",
], ],
"entity_map": { "entity_map": {
@ -2171,16 +2077,6 @@ DEVICES = [
"entity_class": "Battery", "entity_class": "Battery",
"entity_id": "sensor.lumi_lumi_sensor_smoke_77665544_power", "entity_id": "sensor.lumi_lumi_sensor_smoke_77665544_power",
}, },
("sensor", "00:11:22:33:44:55:66:77-1-12"): {
"channels": ["analog_input"],
"entity_class": "AnalogInput",
"entity_id": "sensor.lumi_lumi_sensor_smoke_77665544_analog_input",
},
("sensor", "00:11:22:33:44:55:66:77-1-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_sensor_smoke_77665544_multistate_input",
},
("binary_sensor", "00:11:22:33:44:55:66:77-1-1280"): { ("binary_sensor", "00:11:22:33:44:55:66:77-1-1280"): {
"channels": ["ias_zone"], "channels": ["ias_zone"],
"entity_class": "IASZone", "entity_class": "IASZone",
@ -2254,21 +2150,13 @@ DEVICES = [
"profile_id": 260, "profile_id": 260,
} }
}, },
"entities": [ "entities": ["sensor.lumi_lumi_sensor_switch_aq3_77665544_power"],
"sensor.lumi_lumi_sensor_switch_aq3_77665544_multistate_input",
"sensor.lumi_lumi_sensor_switch_aq3_77665544_power",
],
"entity_map": { "entity_map": {
("sensor", "00:11:22:33:44:55:66:77-1-1"): { ("sensor", "00:11:22:33:44:55:66:77-1-1"): {
"channels": ["power"], "channels": ["power"],
"entity_class": "Battery", "entity_class": "Battery",
"entity_id": "sensor.lumi_lumi_sensor_switch_aq3_77665544_power", "entity_id": "sensor.lumi_lumi_sensor_switch_aq3_77665544_power",
}, },
("sensor", "00:11:22:33:44:55:66:77-1-18"): {
"channels": ["multistate_input"],
"entity_class": "Text",
"entity_id": "sensor.lumi_lumi_sensor_switch_aq3_77665544_multistate_input",
},
}, },
"event_channels": ["1:0x0006"], "event_channels": ["1:0x0006"],
"manufacturer": "LUMI", "manufacturer": "LUMI",