Skip to content

Commit

Permalink
Merge pull request #68 from mlq/feature/shelly-plus-total-energy
Browse files Browse the repository at this point in the history
Use different divider for Gen 2 power meters
  • Loading branch information
hakana authored Apr 27, 2022
2 parents a0c19ff + 08f5815 commit 83462e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyShelly/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions pyShelly/powermeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit 83462e7

Please sign in to comment.