Add Off-peak power control to Roborock (#97307)
* add off-peak switch and time * Make off_peak disabled by default
This commit is contained in:
parent
02c27d8ad2
commit
2841cbbed2
3 changed files with 66 additions and 0 deletions
|
@ -150,6 +150,9 @@
|
|||
"dnd_switch": {
|
||||
"name": "Do not disturb"
|
||||
},
|
||||
"off_peak_switch": {
|
||||
"name": "Off-peak charging"
|
||||
},
|
||||
"status_indicator": {
|
||||
"name": "Status indicator light"
|
||||
}
|
||||
|
@ -160,6 +163,12 @@
|
|||
},
|
||||
"dnd_end_time": {
|
||||
"name": "Do not disturb end"
|
||||
},
|
||||
"off_peak_start_time": {
|
||||
"name": "Off-peak start"
|
||||
},
|
||||
"off_peak_end_time": {
|
||||
"name": "Off-peak end"
|
||||
}
|
||||
},
|
||||
"vacuum": {
|
||||
|
|
|
@ -84,6 +84,25 @@ SWITCH_DESCRIPTIONS: list[RoborockSwitchDescription] = [
|
|||
icon="mdi:bell-cancel",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
),
|
||||
RoborockSwitchDescription(
|
||||
cache_key=CacheableAttribute.valley_electricity_timer,
|
||||
update_value=lambda cache, value: cache.update_value(
|
||||
[
|
||||
cache.value.get("start_hour"),
|
||||
cache.value.get("start_minute"),
|
||||
cache.value.get("end_hour"),
|
||||
cache.value.get("end_minute"),
|
||||
]
|
||||
)
|
||||
if value
|
||||
else cache.close_value(),
|
||||
attribute="enabled",
|
||||
key="off_peak_switch",
|
||||
translation_key="off_peak_switch",
|
||||
icon="mdi:power-plug",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -79,6 +79,44 @@ TIME_DESCRIPTIONS: list[RoborockTimeDescription] = [
|
|||
),
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
),
|
||||
RoborockTimeDescription(
|
||||
key="off_peak_start",
|
||||
translation_key="off_peak_start",
|
||||
icon="mdi:power-plug",
|
||||
cache_key=CacheableAttribute.valley_electricity_timer,
|
||||
update_value=lambda cache, desired_time: cache.update_value(
|
||||
[
|
||||
desired_time.hour,
|
||||
desired_time.minute,
|
||||
cache.value.get("end_hour"),
|
||||
cache.value.get("end_minute"),
|
||||
]
|
||||
),
|
||||
get_value=lambda cache: datetime.time(
|
||||
hour=cache.value.get("start_hour"), minute=cache.value.get("start_minute")
|
||||
),
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
RoborockTimeDescription(
|
||||
key="off_peak_end",
|
||||
translation_key="off_peak_end",
|
||||
icon="mdi:power-plug-off",
|
||||
cache_key=CacheableAttribute.valley_electricity_timer,
|
||||
update_value=lambda cache, desired_time: cache.update_value(
|
||||
[
|
||||
cache.value.get("start_hour"),
|
||||
cache.value.get("start_minute"),
|
||||
desired_time.hour,
|
||||
desired_time.minute,
|
||||
]
|
||||
),
|
||||
get_value=lambda cache: datetime.time(
|
||||
hour=cache.value.get("end_hour"), minute=cache.value.get("end_minute")
|
||||
),
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue