From 08f58152f103524f57eba644e686d926ef9150de Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Tue, 12 Apr 2022 23:08:26 +0200 Subject: [PATCH] Use different divider for Gen 2 power meters --- pyShelly/block.py | 4 ++-- pyShelly/powermeter.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyShelly/block.py b/pyShelly/block.py index f6f16cb..34ec971 100644 --- a/pyShelly/block.py +++ b/pyShelly/block.py @@ -392,7 +392,7 @@ def setup_devices(self): elif self.type == 'ShellyPlus1PM': self.rpc = True self._add_device(Relay(self, 0)) - self._add_device(PowerMeter(self, 0)) + self._add_device(PowerMeter(self, 0, gen=2)) self._add_device(Switch(self, 0)) #Shelly 2 elif self.type == 'SHSW-21': @@ -437,7 +437,7 @@ def setup_devices(self): self.rpc = True for channel in range(4): self._add_device(Relay(self, channel + 1)) - self._add_device(PowerMeter(self, channel + 1)) + self._add_device(PowerMeter(self, channel + 1, gen=2)) self._add_device(Switch(self, channel + 1)) elif self.type == 'SHRGBWW-01': self._add_device(RGBWW(self)) diff --git a/pyShelly/powermeter.py b/pyShelly/powermeter.py index 6604d11..ed9aca5 100644 --- a/pyShelly/powermeter.py +++ b/pyShelly/powermeter.py @@ -19,7 +19,7 @@ class PowerMeter(Device): """Class to represent a power meter value""" def __init__(self, block, channel, position = None, - tot_pos = None, voltage_to_block=False, em=False, topic="emeter"): + tot_pos = None, voltage_to_block=False, em=False, topic="emeter", gen=1): #Todo: voltage_to_block super(PowerMeter, self).__init__(block) self.id = block.id @@ -48,7 +48,7 @@ def __init__(self, block, channel, position = None, ATTR_TOPIC: ['relay/$/power', topic + '/$/power'], ATTR_RPC: 'switch:$/apower' } - divider = None if em else '/60' + divider = None if (em or gen == 2) else '/60' self._info_value_cfg = { INFO_VALUE_POWER_FACTOR : { ATTR_POS: [114, 4110],