Skip to content

Commit

Permalink
Add duration=0 when ramp_time used for HmIP-RGBW (#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Jan 3, 2024
1 parent 9e5f079 commit 05c7f4c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 2024.1.0 (2024-01-03)

- Add duration=0 when ramp_time used for HmIP-RGBW

# Version 2023.12.4 (2023-12-19)

- Add HB-LC-Bl1-Velux to cover
Expand Down
4 changes: 3 additions & 1 deletion hahomematic/platforms/custom/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@
ED.PRIMARY_CHANNEL: 1,
ED.SECONDARY_CHANNELS: (2, 3, 4),
ED.REPEATABLE_FIELDS: {
Field.DIRECTION: Parameter.ACTIVITY_STATE,
Field.COLOR_TEMPERATURE: Parameter.COLOR_TEMPERATURE,
Field.DIRECTION: Parameter.ACTIVITY_STATE,
Field.ON_TIME_VALUE: Parameter.DURATION_VALUE,
Field.ON_TIME_UNIT: Parameter.DURATION_UNIT,
Field.EFFECT: Parameter.EFFECT,
Field.HUE: Parameter.HUE,
Field.LEVEL: Parameter.LEVEL,
Expand Down
14 changes: 14 additions & 0 deletions hahomematic/platforms/custom/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ def _init_entity_fields(self) -> None:
self._e_device_operation_mode: HmSelect = self._get_entity(
field=Field.DEVICE_OPERATION_MODE, entity_type=HmSelect
)
self._e_on_time_unit: HmAction = self._get_entity(
field=Field.ON_TIME_UNIT, entity_type=HmAction
)
self._e_effect: HmAction = self._get_entity(field=Field.EFFECT, entity_type=HmAction)
self._e_hue: HmInteger = self._get_entity(field=Field.HUE, entity_type=HmInteger)
self._e_ramp_time_to_off_unit: HmAction = self._get_entity(
Expand Down Expand Up @@ -524,11 +527,22 @@ async def turn_on(
await self._e_color_temperature_kelvin.send_value(
value=color_temp_kelvin, collector=collector
)
if kwargs.get("on_time") is None and kwargs.get("ramp_time"):
await self._set_on_time_value(on_time=0, collector=collector)
if self.supports_effects and (effect := kwargs.get("effect")) is not None:
await self._e_effect.send_value(value=effect, collector=collector)

await super().turn_on(collector=collector, **kwargs)

@bind_collector
async def _set_on_time_value(
self, on_time: float, collector: CallParameterCollector | None = None
) -> None:
"""Set the on time value in seconds."""
on_time, on_time_unit = _recalc_unit_timer(time=on_time)
await self._e_on_time_unit.send_value(value=on_time_unit, collector=collector)
await self._e_on_time_value.send_value(value=float(on_time), collector=collector)

async def _set_ramp_time_on_value(
self, ramp_time: float, collector: CallParameterCollector | None = None
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "hahomematic"
version = "2023.12.4"
version = "2024.1.0"
license = {text = "MIT License"}
description = "Homematic interface for Home Assistant running on Python 3."
readme = "README.md"
Expand Down
18 changes: 17 additions & 1 deletion tests/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from hahomematic.const import EntityUsage
from hahomematic.const import EntityUsage, ParamsetKey
from hahomematic.platforms.custom.light import (
CeColorDimmer,
CeColorDimmerEffect,
Expand All @@ -16,6 +16,7 @@
CeIpRGBWLight,
ColorBehaviour,
FixedColor,
TimeUnit,
)

from tests import const, helper
Expand Down Expand Up @@ -843,3 +844,18 @@ async def test_ceiprgbwlight(factory: helper.Factory) -> None:
assert mock_client.method_calls[-1] == call.put_paramset(
address="VCU5629873:1", paramset_key="VALUES", value={"EFFECT": 1, "LEVEL": 1.0}
)

await light.turn_on(hs_color=(44, 66), ramp_time=5)
assert mock_client.method_calls[-1] == call.put_paramset(
address="VCU5629873:1",
paramset_key=ParamsetKey.VALUES,
value={
"HUE": 44,
"SATURATION": 0.66,
"DURATION_UNIT": TimeUnit.SECONDS,
"DURATION_VALUE": 0,
"RAMP_TIME_UNIT": TimeUnit.SECONDS,
"RAMP_TIME_VALUE": 5,
"LEVEL": 1.0,
},
)

0 comments on commit 05c7f4c

Please sign in to comment.