From f30c636fb7eb0d22a2ec360978ea6960eafa6d51 Mon Sep 17 00:00:00 2001 From: Jonathan Keljo Date: Sun, 16 Feb 2020 20:33:00 -0800 Subject: [PATCH] Fix bugs in greeneye_monitor voltage reporting (#31895) * Fix #31870 * Fix voltage notifications too --- homeassistant/components/greeneye_monitor/sensor.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/greeneye_monitor/sensor.py b/homeassistant/components/greeneye_monitor/sensor.py index 19ef7529b0a..2640c701f92 100644 --- a/homeassistant/components/greeneye_monitor/sensor.py +++ b/homeassistant/components/greeneye_monitor/sensor.py @@ -294,12 +294,10 @@ class VoltageSensor(GEMSensor): def __init__(self, monitor_serial_number, number, name): """Construct the entity.""" super().__init__(monitor_serial_number, name, "volts", number) - self._monitor = None def _get_sensor(self, monitor): - """Wire the updates to a current channel.""" - self._monitor = monitor - return monitor.channels[self._number - 1] + """Wire the updates to the monitor itself, since there is no voltage element in the API.""" + return monitor @property def icon(self): @@ -309,10 +307,10 @@ class VoltageSensor(GEMSensor): @property def state(self): """Return the current voltage being reported by this sensor.""" - if not self._monitor.voltage: + if not self._sensor: return None - return self._monitor.voltage + return self._sensor.voltage @property def unit_of_measurement(self):