From d1c04750cd629eee447234e98d175b8d3196782d Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Thu, 1 Oct 2020 12:08:03 +0200 Subject: [PATCH] Add voltage, power factor and energy returned sensors to Shelly integration (#40681) --- homeassistant/components/shelly/sensor.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 14c1b645118..e82f167ca60 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -8,6 +8,7 @@ from homeassistant.const import ( LIGHT_LUX, PERCENTAGE, POWER_WATT, + VOLT, ) from .entity import ( @@ -53,6 +54,18 @@ SENSORS = { value=lambda value: round(value, 1), device_class=sensor.DEVICE_CLASS_POWER, ), + ("emeter", "voltage"): BlockAttributeDescription( + name="Voltage", + unit=VOLT, + value=lambda value: round(value, 1), + device_class=sensor.DEVICE_CLASS_VOLTAGE, + ), + ("emeter", "powerFactor"): BlockAttributeDescription( + name="Power Factor", + unit=PERCENTAGE, + value=lambda value: round(value * 100, 1), + device_class=sensor.DEVICE_CLASS_POWER_FACTOR, + ), ("relay", "power"): BlockAttributeDescription( name="Power", unit=POWER_WATT, @@ -77,6 +90,12 @@ SENSORS = { value=lambda value: round(value / 1000, 2), device_class=sensor.DEVICE_CLASS_ENERGY, ), + ("emeter", "energyReturned"): BlockAttributeDescription( + name="Energy Returned", + unit=ENERGY_KILO_WATT_HOUR, + value=lambda value: round(value / 1000, 2), + device_class=sensor.DEVICE_CLASS_ENERGY, + ), ("light", "energy"): BlockAttributeDescription( name="Energy", unit=ENERGY_KILO_WATT_HOUR,