Skip to content

Commit

Permalink
Add actions to get/store climate profile
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ committed Oct 11, 2024
1 parent c4eded8 commit 32e752f
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 2 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ Returns a paramset
Call to `getParamset` for direct connections on the XML-RPC interface.
Returns a paramset

### `homematicip_local.get_schedule_profile`

Returns the schedule of a climate profile.

### `homematicip_local.get_schedule_profile_weekday`

Returns the schedule of a climate profile for a certain weekday.
Expand All @@ -390,6 +394,15 @@ Set a device parameter via the XML-RPC interface. Preferred when using the UI. W

Turn on the install mode on the provided Interface to pair new devices.

### `homematicip_local.set_schedule_profile` (experimental)

Sends the schedule of a climate profile to a device.

Relevant rules for modifying a schedule:
- All weekdays must be included
- All rules of `homematicip_local.set_schedule_profile_weekday` are relevant
- The required data structure can be retrieved with `homematicip_local.get_schedule_profile`

### `homematicip_local.set_schedule_profile_weekday` (experimental)

Sends the schedule of a climate profile for a certain weekday to a device.
Expand All @@ -409,7 +422,7 @@ Relevant rules for modifying a schedule:
- The temperature must be in the defined temperature range of the device.
- The time of a slot is defined in minutes from midnight.
- The slot is defined by the end time. The start time is the end time of the previous slot or 0.
- The time of a slot must be equal or higher then the previous slot, and must be in a range between 0 and 1440. If you have retrieved a schedule with `homematicip_local.set_schedule_profile_weekday` this might not be the case, but must be fixed before sending.
- The time of a slot must be equal or higher then the previous slot, and must be in a range between 0 and 1440. If you have retrieved a schedule with `homematicip_local.get_schedule_profile_weekday` this might not be the case, but must be fixed before sending.

### `homematicip_local.set_variable_value`

Expand Down
34 changes: 33 additions & 1 deletion custom_components/homematicip_local/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from hahomematic.const import HmPlatform
from hahomematic.platforms.custom import (
HM_PRESET_MODE_PREFIX,
PROFILE_DICT,
WEEKDAY_DICT,
BaseClimateEntity,
HmHvacAction,
Expand Down Expand Up @@ -45,7 +46,9 @@
SERVICE_DISABLE_AWAY_MODE,
SERVICE_ENABLE_AWAY_MODE_BY_CALENDAR,
SERVICE_ENABLE_AWAY_MODE_BY_DURATION,
SERVICE_GET_SCHEDULE_PROFILE,
SERVICE_GET_SCHEDULE_PROFILE_WEEKDAY,
SERVICE_SET_SCHEDULE_PROFILE,
SERVICE_SET_SCHEDULE_PROFILE_WEEKDAY,
)
from .control_unit import ControlUnit, signal_new_hm_entity
Expand All @@ -55,9 +58,10 @@

ATTR_AWAY_END: Final = "end"
ATTR_AWAY_HOURS: Final = "hours"
ATTR_AWAY_TEMPERATURE: Final = "away_temperature"
ATTR_AWAY_START: Final = "start"
ATTR_AWAY_TEMPERATURE: Final = "away_temperature"
ATTR_PROFILE: Final = "profile"
ATTR_PROFILE_DATA: Final = "profile_data"
ATTR_WEEKDAY: Final = "weekday"
ATTR_WEEKDAY_DATA: Final = "weekday_data"

Expand Down Expand Up @@ -147,6 +151,15 @@ def async_add_climate(hm_entities: tuple[BaseClimateEntity, ...]) -> None:
func="async_disable_away_mode",
)

platform.async_register_entity_service(
name=SERVICE_GET_SCHEDULE_PROFILE,
schema={
vol.Required(ATTR_PROFILE): cv.string,
},
supports_response=SupportsResponse.OPTIONAL,
func="async_get_schedule_profile",
)

platform.async_register_entity_service(
name=SERVICE_GET_SCHEDULE_PROFILE_WEEKDAY,
schema={
Expand All @@ -157,6 +170,15 @@ def async_add_climate(hm_entities: tuple[BaseClimateEntity, ...]) -> None:
func="async_get_schedule_profile_weekday",
)

platform.async_register_entity_service(
name=SERVICE_SET_SCHEDULE_PROFILE,
schema={
vol.Required(ATTR_PROFILE): cv.string,
vol.Required(ATTR_PROFILE_DATA): dict,
},
func="async_set_schedule_profile",
)

platform.async_register_entity_service(
name=SERVICE_SET_SCHEDULE_PROFILE_WEEKDAY,
schema={
Expand Down Expand Up @@ -344,12 +366,22 @@ async def async_disable_away_mode(self) -> None:
"""Disable the away mode on thermostat."""
await self._hm_entity.disable_away_mode()

async def async_get_schedule_profile(self, profile: str) -> ServiceResponse:
"""Return the schedule profile."""
return await self._hm_entity.get_profile(profile=profile) # type: ignore[no-any-return]

async def async_get_schedule_profile_weekday(
self, profile: str, weekday: str
) -> ServiceResponse:
"""Return the schedule profile weekday."""
return await self._hm_entity.get_profile_weekday(profile=profile, weekday=weekday) # type: ignore[no-any-return]

async def async_set_schedule_profile(self, profile: str, profile_data: PROFILE_DICT) -> None:
"""Set the schedule profile."""
for p_key, p_value in profile_data.items():
profile_data[p_key] = {int(key): value for key, value in p_value.items()}
await self._hm_entity.set_profile(profile=profile, profile_data=profile_data)

async def async_set_schedule_profile_weekday(
self, profile: str, weekday: str, weekday_data: WEEKDAY_DICT
) -> None:
Expand Down
4 changes: 4 additions & 0 deletions custom_components/homematicip_local/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@
SERVICE_GET_LINK_PARAMSET: Final = "get_link_paramset"
SERVICE_GET_LINK_PEERS: Final = "get_link_peers"
SERVICE_GET_PARAMSET: Final = "get_paramset"
SERVICE_GET_SCHEDULE_PROFILE: Final = "get_schedule_profile"
SERVICE_GET_SCHEDULE_PROFILE_WEEKDAY: Final = "get_schedule_profile_weekday"
SERVICE_LIGHT_SET_ON_TIME: Final = "light_set_on_time"
SERVICE_PUT_LINK_PARAMSET: Final = "put_link_paramset"
SERVICE_PUT_PARAMSET: Final = "put_paramset"
SERVICE_SET_COVER_COMBINED_POSITION: Final = "set_cover_combined_position"
SERVICE_SET_DEVICE_VALUE: Final = "set_device_value"
SERVICE_SET_INSTALL_MODE: Final = "set_install_mode"
SERVICE_SET_SCHEDULE_PROFILE: Final = "set_schedule_profile"
SERVICE_SET_SCHEDULE_PROFILE_WEEKDAY: Final = "set_schedule_profile_weekday"
SERVICE_SET_VARIABLE_VALUE: Final = "set_variable_value"
SERVICE_SWITCH_SET_ON_TIME: Final = "switch_set_on_time"
Expand All @@ -91,13 +93,15 @@
SERVICE_GET_LINK_PARAMSET,
SERVICE_GET_LINK_PEERS,
SERVICE_GET_PARAMSET,
SERVICE_GET_SCHEDULE_PROFILE,
SERVICE_GET_SCHEDULE_PROFILE_WEEKDAY,
SERVICE_LIGHT_SET_ON_TIME,
SERVICE_PUT_LINK_PARAMSET,
SERVICE_PUT_PARAMSET,
SERVICE_SET_COVER_COMBINED_POSITION,
SERVICE_SET_DEVICE_VALUE,
SERVICE_SET_INSTALL_MODE,
SERVICE_SET_SCHEDULE_PROFILE,
SERVICE_SET_SCHEDULE_PROFILE_WEEKDAY,
SERVICE_SET_VARIABLE_VALUE,
SERVICE_SWITCH_SET_ON_TIME,
Expand Down
40 changes: 40 additions & 0 deletions custom_components/homematicip_local/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,24 @@ get_paramset:
options:
- "MASTER"
- "VALUES"
get_schedule_profile:
target:
entity:
domain: climate
integration: homematicip_local
fields:
profile:
required: true
example: P1
selector:
select:
options:
- "P1"
- "P2"
- "P3"
- "P4"
- "P5"
- "P6"
get_schedule_profile_weekday:
target:
entity:
Expand Down Expand Up @@ -150,6 +168,28 @@ get_schedule_profile_weekday:
- "FRIDAY"
- "SATURDAY"
- "SUNDAY"
set_schedule_profile:
target:
entity:
domain: climate
integration: homematicip_local
fields:
profile:
required: true
example: P1
selector:
select:
options:
- "P1"
- "P2"
- "P3"
- "P4"
- "P5"
- "P6"
profile_data:
required: true
selector:
object:
set_schedule_profile_weekday:
target:
entity:
Expand Down
24 changes: 24 additions & 0 deletions custom_components/homematicip_local/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,16 @@
},
"name": "Get paramset"
},
"get_schedule_profile": {
"description": "Call to get a schedule of a climate device.",
"fields": {
"profile": {
"description": "Select a profile.",
"name": "Profile"
}
},
"name": "Get schedule profile"
},
"get_schedule_profile_weekday": {
"description": "Call to get a schedule of a climate device.",
"fields": {
Expand Down Expand Up @@ -946,6 +956,20 @@
},
"name": "Set install mode"
},
"set_schedule_profile": {
"description": "Call to store a schedule on a climate device.",
"fields": {
"profile": {
"description": "Select a profile.",
"name": "Profile"
},
"profile_data": {
"description": "Data for a profile",
"name": "Profile data"
}
},
"name": "Set schedule profile"
},
"set_schedule_profile_weekday": {
"description": "Call to store a schedule on a climate device.",
"fields": {
Expand Down
24 changes: 24 additions & 0 deletions custom_components/homematicip_local/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,16 @@
},
"name": "Parametersatz von einem Gerät oder Kanal lesen"
},
"get_schedule_profile": {
"description": "Aufruf um einen Zeitplan von einem Thermostat abzurufen",
"fields": {
"profile": {
"description": "Wähle ein Profil",
"name": "Profil"
}
},
"name": "Zeitplan abrufen"
},
"get_schedule_profile_weekday": {
"description": "Aufruf um einen Zeitplan von einem Thermostat abzurufen",
"fields": {
Expand Down Expand Up @@ -950,6 +960,20 @@
},
"name": "Anlernmodus auf der Homematic-Zentrale aktivieren"
},
"set_schedule_profile": {
"description": "Speichert einen Zeitplan auf einem Thermostat",
"fields": {
"profile": {
"description": "Wähle ein Profil",
"name": "Profil"
},
"profile_data": {
"description": "Daten für ein Profil",
"name": "Profildaten"
}
},
"name": "Zeitplan speichern"
},
"set_schedule_profile_weekday": {
"description": "Speichert einen Zeitplan auf einem Thermostat",
"fields": {
Expand Down
24 changes: 24 additions & 0 deletions custom_components/homematicip_local/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,16 @@
},
"name": "Get paramset"
},
"get_schedule_profile": {
"description": "Call to get a schedule of a climate device.",
"fields": {
"profile": {
"description": "Select a profile.",
"name": "Profile"
}
},
"name": "Get schedule profile"
},
"get_schedule_profile_weekday": {
"description": "Call to get a schedule of a climate device.",
"fields": {
Expand Down Expand Up @@ -946,6 +956,20 @@
},
"name": "Set install mode"
},
"set_schedule_profile": {
"description": "Call to store a schedule on a climate device.",
"fields": {
"profile": {
"description": "Select a profile.",
"name": "Profile"
},
"profile_data": {
"description": "Data for a profile",
"name": "Profile data"
}
},
"name": "Set schedule profile"
},
"set_schedule_profile_weekday": {
"description": "Call to store a schedule on a climate device.",
"fields": {
Expand Down

0 comments on commit 32e752f

Please sign in to comment.