Skip to content

Commit

Permalink
Using default holiday setpoint in away mode for vrc700 controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
signalkraft committed Mar 20, 2024
1 parent 0efa72a commit 09bbcf9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
14 changes: 11 additions & 3 deletions custom_components/mypyllant/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from custom_components.mypyllant.const import DOMAIN
from custom_components.mypyllant.const import DOMAIN, DEFAULT_HOLIDAY_SETPOINT
from custom_components.mypyllant.coordinator import SystemCoordinator
from custom_components.mypyllant.utils import HolidayEntity, EntityList
from myPyllant.utils import get_default_holiday_dates
Expand Down Expand Up @@ -60,7 +60,12 @@ async def async_set_value(self, value: datetime) -> None:
self.system.timezone,
self.default_holiday_duration,
)
await self.coordinator.api.set_holiday(self.system, start=value, end=end)
setpoint = None
if self.system.control_identifier.is_vrc700:
setpoint = DEFAULT_HOLIDAY_SETPOINT
await self.coordinator.api.set_holiday(
self.system, start=value, end=end, setpoint=setpoint
)
# Holiday values need a long time to show up in the API
await self.coordinator.async_request_refresh_delayed(10)

Expand All @@ -86,8 +91,11 @@ def native_value(self):

async def async_set_value(self, value: datetime) -> None:
# TODO: Make API tz-aware
setpoint = None
if self.system.control_identifier.is_vrc700:
setpoint = DEFAULT_HOLIDAY_SETPOINT
await self.coordinator.api.set_holiday(
self.system, start=self.holiday_start, end=value
self.system, start=self.holiday_start, end=value, setpoint=setpoint
)
# Holiday values need a long time to show up in the API
await self.coordinator.async_request_refresh_delayed(10)
Expand Down
9 changes: 7 additions & 2 deletions custom_components/mypyllant/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from custom_components.mypyllant.const import DOMAIN
from custom_components.mypyllant.const import DOMAIN, DEFAULT_HOLIDAY_SETPOINT
from custom_components.mypyllant.coordinator import SystemCoordinator
from custom_components.mypyllant.utils import (
HolidayEntity,
Expand Down Expand Up @@ -102,7 +102,12 @@ async def async_set_native_value(self, value: float) -> None:
if self.native_unit_of_measurement == UnitOfTime.DAYS:
value = value * 24
end = datetime.now(self.system.timezone) + timedelta(hours=value)
await self.coordinator.api.set_holiday(self.system, end=end)
setpoint = None
if self.system.control_identifier.is_vrc700:
setpoint = DEFAULT_HOLIDAY_SETPOINT
await self.coordinator.api.set_holiday(
self.system, end=end, setpoint=setpoint
)
# Holiday values need a long time to show up in the API
await self.coordinator.async_request_refresh_delayed(20)

Expand Down
7 changes: 5 additions & 2 deletions custom_components/mypyllant/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from custom_components.mypyllant.const import DOMAIN
from custom_components.mypyllant.const import DOMAIN, DEFAULT_HOLIDAY_SETPOINT
from custom_components.mypyllant.coordinator import SystemCoordinator
from custom_components.mypyllant.utils import (
HolidayEntity,
Expand Down Expand Up @@ -59,7 +59,10 @@ async def async_turn_on(self, **kwargs):
self.system.timezone,
self.default_holiday_duration,
)
await self.coordinator.api.set_holiday(self.system, end=end)
setpoint = None
if self.system.control_identifier.is_vrc700:
setpoint = DEFAULT_HOLIDAY_SETPOINT
await self.coordinator.api.set_holiday(self.system, end=end, setpoint=setpoint)
# Holiday values need a long time to show up in the API
await self.coordinator.async_request_refresh_delayed(20)

Expand Down

0 comments on commit 09bbcf9

Please sign in to comment.