Skip to content

Commit

Permalink
Merge pull request #22 from sreknob/patch-1
Browse files Browse the repository at this point in the history
zha support for ICTCG1Controller
  • Loading branch information
xaviml authored Feb 5, 2020
2 parents 457f598 + c81d7a2 commit 733b25b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion apps/controllerx/core/type/light_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ async def toggle(self):

@action
async def on_full(self, attribute):
await self.on()
attribute = await self.get_attribute(attribute)
stepper = self.manual_steppers[attribute]
await self.change_light_state(
stepper.minmax.min, attribute, Stepper.UP, stepper,
stepper.minmax.max, attribute, Stepper.UP, stepper,
)

async def get_attribute(self, attribute):
Expand Down
11 changes: 11 additions & 0 deletions apps/controllerx/devices/ikea.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ def get_z2m_actions_mapping(self):
"rotate_stop": Light.RELEASE,
}

def get_zha_actions_mapping(self):
return {
"move_1_70": Light.HOLD_BRIGHTNESS_DOWN,
"move_1_195": Light.HOLD_BRIGHTNESS_DOWN,
"move_to_level_with_on_off_0_1": "rotate_left_quick",
"move_with_on_off_0_70": Light.HOLD_BRIGHTNESS_UP,
"move_with_on_off_0_195": Light.ON,
"move_to_level_with_on_off_255_1": "rotate_right_quick",
"stop": Light.RELEASE,
}


class E1744LightController(LightController):
# Different states reported from the controller:
Expand Down
6 changes: 3 additions & 3 deletions tests/core/type/light_controller_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ async def test_toggle(sut, mocker):
@pytest.mark.asyncio
async def test_on_full(sut, mocker):
attribute = "test_attribute"
min_ = 1
max_ = 10
change_light_state_patch = mocker.patch.object(sut, "change_light_state")
stepper = MinMaxStepper(min_, 10, 10)
stepper = MinMaxStepper(1, max_, 10)
sut.manual_steppers = {attribute: stepper}
await sut.on_full(attribute)
change_light_state_patch.assert_called_once_with(
min_, attribute, Stepper.UP, stepper
max_, attribute, Stepper.UP, stepper
)


Expand Down

0 comments on commit 733b25b

Please sign in to comment.