mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Improve energy meter support of fibaro sensor (#71072)
This commit is contained in:
parent
d90937182e
commit
57d0390882
@ -33,27 +33,43 @@ SENSOR_TYPES = {
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
SensorDeviceClass.TEMPERATURE,
|
SensorDeviceClass.TEMPERATURE,
|
||||||
|
SensorStateClass.MEASUREMENT,
|
||||||
],
|
],
|
||||||
"com.fibaro.smokeSensor": [
|
"com.fibaro.smokeSensor": [
|
||||||
"Smoke",
|
"Smoke",
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
"mdi:fire",
|
"mdi:fire",
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
],
|
],
|
||||||
"CO2": [
|
"CO2": [
|
||||||
"CO2",
|
"CO2",
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
SensorDeviceClass.CO2,
|
SensorDeviceClass.CO2,
|
||||||
|
SensorStateClass.MEASUREMENT,
|
||||||
],
|
],
|
||||||
"com.fibaro.humiditySensor": [
|
"com.fibaro.humiditySensor": [
|
||||||
"Humidity",
|
"Humidity",
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
None,
|
None,
|
||||||
SensorDeviceClass.HUMIDITY,
|
SensorDeviceClass.HUMIDITY,
|
||||||
|
SensorStateClass.MEASUREMENT,
|
||||||
|
],
|
||||||
|
"com.fibaro.lightSensor": [
|
||||||
|
"Light",
|
||||||
|
LIGHT_LUX,
|
||||||
|
None,
|
||||||
|
SensorDeviceClass.ILLUMINANCE,
|
||||||
|
SensorStateClass.MEASUREMENT,
|
||||||
|
],
|
||||||
|
"com.fibaro.energyMeter": [
|
||||||
|
"Energy",
|
||||||
|
ENERGY_KILO_WATT_HOUR,
|
||||||
|
None,
|
||||||
|
SensorDeviceClass.ENERGY,
|
||||||
|
SensorStateClass.TOTAL_INCREASING,
|
||||||
],
|
],
|
||||||
"com.fibaro.lightSensor": ["Light", LIGHT_LUX, None, SensorDeviceClass.ILLUMINANCE],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -66,7 +82,7 @@ async def async_setup_entry(
|
|||||||
entities: list[SensorEntity] = []
|
entities: list[SensorEntity] = []
|
||||||
for device in hass.data[DOMAIN][entry.entry_id][FIBARO_DEVICES][Platform.SENSOR]:
|
for device in hass.data[DOMAIN][entry.entry_id][FIBARO_DEVICES][Platform.SENSOR]:
|
||||||
entities.append(FibaroSensor(device))
|
entities.append(FibaroSensor(device))
|
||||||
for platform in (Platform.COVER, Platform.LIGHT, Platform.SWITCH):
|
for platform in (Platform.COVER, Platform.LIGHT, Platform.SENSOR, Platform.SWITCH):
|
||||||
for device in hass.data[DOMAIN][entry.entry_id][FIBARO_DEVICES][platform]:
|
for device in hass.data[DOMAIN][entry.entry_id][FIBARO_DEVICES][platform]:
|
||||||
if "energy" in device.interfaces:
|
if "energy" in device.interfaces:
|
||||||
entities.append(FibaroEnergySensor(device))
|
entities.append(FibaroEnergySensor(device))
|
||||||
@ -89,6 +105,7 @@ class FibaroSensor(FibaroDevice, SensorEntity):
|
|||||||
self._unit = SENSOR_TYPES[fibaro_device.type][1]
|
self._unit = SENSOR_TYPES[fibaro_device.type][1]
|
||||||
self._icon = SENSOR_TYPES[fibaro_device.type][2]
|
self._icon = SENSOR_TYPES[fibaro_device.type][2]
|
||||||
self._device_class = SENSOR_TYPES[fibaro_device.type][3]
|
self._device_class = SENSOR_TYPES[fibaro_device.type][3]
|
||||||
|
self._attr_state_class = SENSOR_TYPES[fibaro_device.type][4]
|
||||||
else:
|
else:
|
||||||
self._unit = None
|
self._unit = None
|
||||||
self._icon = None
|
self._icon = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user