Skip to content

Commit

Permalink
New sensor for TRVZB Voltage
Browse files Browse the repository at this point in the history
  • Loading branch information
bob-tm authored Jan 22, 2025
1 parent 7f64250 commit 8e4c154
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions custom_components/sonoff/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,18 @@ def internal_update(self, params: dict = None):

if self.hass:
self._async_write_ha_state()


class XHexVoltageTRVZB(XSensor):
_attr_device_class = SensorDeviceClass.VOLTAGE
_attr_native_unit_of_measurement = UnitOfElectricPotential.VOLT

def set_state(self, params: dict = None, value: float = None):
try:
value = params[self.param]
value = int(value, 16) * 0.001

if value != 0:
XSensor.set_state(self, value=value)
except Exception:
XSensor.set_state(self)

0 comments on commit 8e4c154

Please sign in to comment.