Skip to content

Commit

Permalink
Improve energy meter support of fibaro sensor (#71072)
Browse files Browse the repository at this point in the history
  • Loading branch information
rappenze committed Apr 29, 2022
1 parent d909371 commit 57d0390
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions homeassistant/components/fibaro/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,43 @@
None,
None,
SensorDeviceClass.TEMPERATURE,
SensorStateClass.MEASUREMENT,
],
"com.fibaro.smokeSensor": [
"Smoke",
CONCENTRATION_PARTS_PER_MILLION,
"mdi:fire",
None,
None,
],
"CO2": [
"CO2",
CONCENTRATION_PARTS_PER_MILLION,
None,
None,
SensorDeviceClass.CO2,
SensorStateClass.MEASUREMENT,
],
"com.fibaro.humiditySensor": [
"Humidity",
PERCENTAGE,
None,
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],
}


Expand All @@ -66,7 +82,7 @@ async def async_setup_entry(
entities: list[SensorEntity] = []
for device in hass.data[DOMAIN][entry.entry_id][FIBARO_DEVICES][Platform.SENSOR]:
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]:
if "energy" in device.interfaces:
entities.append(FibaroEnergySensor(device))
Expand All @@ -89,6 +105,7 @@ def __init__(self, fibaro_device):
self._unit = SENSOR_TYPES[fibaro_device.type][1]
self._icon = SENSOR_TYPES[fibaro_device.type][2]
self._device_class = SENSOR_TYPES[fibaro_device.type][3]
self._attr_state_class = SENSOR_TYPES[fibaro_device.type][4]
else:
self._unit = None
self._icon = None
Expand Down

0 comments on commit 57d0390

Please sign in to comment.