Skip to content

Commit

Permalink
added missing fields to SwitchingGroup and added test case for Switch…
Browse files Browse the repository at this point in the history
…ingGroup
  • Loading branch information
coreGreenberet committed May 7, 2018
1 parent d93ae01 commit fc6b02e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 6 additions & 2 deletions homematicip/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,15 @@ def __init__(self,connection):
self.processing = None
self.shutterLevel = None
self.slatsLevel = None
self.dutyCycle = None
self.lowBat = None

def from_json(self, js, devices):
super().from_json(js, devices)
self.on = js["on"]
self.dimLevel = js["dimLevel"]
self.dutyCycle = js["dutyCycle"]
self.lowBat = js["lowBat"]
try: # TODO: FIX that ugly hack -> maybe linked_switching shouldn't inherit anymore from switchingGroup
self.processing = js["processing"]
self.shutterLevel = js["shutterLevel"]
Expand All @@ -150,10 +154,10 @@ def set_shutter_stop(self):
return self._restCall("group/switching/stop", body=json.dumps(data))

def __str__(self):
return "{}: on({}) dimLevel({}) processing({}) shutterLevel({}) slatsLevel({})".format(
return "{}: on({}) dimLevel({}) processing({}) shutterLevel({}) slatsLevel({}) dutyCycle({}) lowBat({})".format(
super().__str__(),
self.on, self.dimLevel, self.processing, self.shutterLevel,
self.slatsLevel)
self.slatsLevel, self.dutyCycle, self.lowBat)


class LinkedSwitchingGroup(SwitchingGroup):
Expand Down
23 changes: 23 additions & 0 deletions tests/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,26 @@ def test_security_group(fake_home):

assert str(g) == ('SECURITY B\xc3\xbcro: windowState(CLOSED) motionDetected(None) presenceDetected(None) sabotage(False)'
' smokeDetectorAlarmType(IDLE_OFF) dutyCycle(False) lowBat(False)')

def test_switching_group(fake_home):
g = fake_home.search_group_by_id('00000000-0000-0000-0000-000000000018')
assert isinstance(g, SwitchingGroup)
for d in g.devices:
assert d.id in ['3014F7110000000000000010', '3014F7110000000000000009', '3014F7110000000000000008']

assert g.dimLevel == None
assert g.dutyCycle == False
assert g.homeId == "00000000-0000-0000-0000-000000000001"
assert g.id == "00000000-0000-0000-0000-000000000018"
assert g.label == "Strom"
assert g.lastStatusUpdate == datetime(2018, 4, 23, 20, 49, 14, 56000) + timedelta(0,utc_offset)
assert g.lowBat == None
assert g.metaGroup.id == "00000000-0000-0000-0000-000000000017"
assert g.on == True
assert g.processing == None
assert g.shutterLevel == None
assert g.slatsLevel == None
assert g.unreach == False

assert str(g) == ('SWITCHING Strom: on(True) dimLevel(None) processing(None) shutterLevel(None) slatsLevel(None)'
' dutyCycle(False) lowBat(None)')

0 comments on commit fc6b02e

Please sign in to comment.