mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add activity type to appropriate RainMachine switches (#117875)
This commit is contained in:
parent
35a20d9c60
commit
881237189d
@ -35,11 +35,11 @@ from .const import (
|
|||||||
from .model import RainMachineEntityDescription
|
from .model import RainMachineEntityDescription
|
||||||
from .util import RUN_STATE_MAP, key_exists
|
from .util import RUN_STATE_MAP, key_exists
|
||||||
|
|
||||||
|
ATTR_ACTIVITY_TYPE = "activity_type"
|
||||||
ATTR_AREA = "area"
|
ATTR_AREA = "area"
|
||||||
ATTR_CS_ON = "cs_on"
|
ATTR_CS_ON = "cs_on"
|
||||||
ATTR_CURRENT_CYCLE = "current_cycle"
|
ATTR_CURRENT_CYCLE = "current_cycle"
|
||||||
ATTR_CYCLES = "cycles"
|
ATTR_CYCLES = "cycles"
|
||||||
ATTR_ZONE_RUN_TIME = "zone_run_time_from_app"
|
|
||||||
ATTR_DELAY = "delay"
|
ATTR_DELAY = "delay"
|
||||||
ATTR_DELAY_ON = "delay_on"
|
ATTR_DELAY_ON = "delay_on"
|
||||||
ATTR_FIELD_CAPACITY = "field_capacity"
|
ATTR_FIELD_CAPACITY = "field_capacity"
|
||||||
@ -55,6 +55,7 @@ ATTR_STATUS = "status"
|
|||||||
ATTR_SUN_EXPOSURE = "sun_exposure"
|
ATTR_SUN_EXPOSURE = "sun_exposure"
|
||||||
ATTR_VEGETATION_TYPE = "vegetation_type"
|
ATTR_VEGETATION_TYPE = "vegetation_type"
|
||||||
ATTR_ZONES = "zones"
|
ATTR_ZONES = "zones"
|
||||||
|
ATTR_ZONE_RUN_TIME = "zone_run_time_from_app"
|
||||||
|
|
||||||
DAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
|
DAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
|
||||||
|
|
||||||
@ -138,6 +139,7 @@ class RainMachineSwitchDescription(
|
|||||||
class RainMachineActivitySwitchDescription(RainMachineSwitchDescription):
|
class RainMachineActivitySwitchDescription(RainMachineSwitchDescription):
|
||||||
"""Describe a RainMachine activity (program/zone) switch."""
|
"""Describe a RainMachine activity (program/zone) switch."""
|
||||||
|
|
||||||
|
kind: str
|
||||||
uid: int
|
uid: int
|
||||||
|
|
||||||
|
|
||||||
@ -211,6 +213,7 @@ async def async_setup_entry(
|
|||||||
key=f"{kind}_{uid}",
|
key=f"{kind}_{uid}",
|
||||||
name=name,
|
name=name,
|
||||||
api_category=api_category,
|
api_category=api_category,
|
||||||
|
kind=kind,
|
||||||
uid=uid,
|
uid=uid,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -225,6 +228,7 @@ async def async_setup_entry(
|
|||||||
key=f"{kind}_{uid}_enabled",
|
key=f"{kind}_{uid}_enabled",
|
||||||
name=f"{name} enabled",
|
name=f"{name} enabled",
|
||||||
api_category=api_category,
|
api_category=api_category,
|
||||||
|
kind=kind,
|
||||||
uid=uid,
|
uid=uid,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -287,6 +291,19 @@ class RainMachineActivitySwitch(RainMachineBaseSwitch):
|
|||||||
_attr_icon = "mdi:water"
|
_attr_icon = "mdi:water"
|
||||||
entity_description: RainMachineActivitySwitchDescription
|
entity_description: RainMachineActivitySwitchDescription
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
entry: ConfigEntry,
|
||||||
|
data: RainMachineData,
|
||||||
|
description: RainMachineSwitchDescription,
|
||||||
|
) -> None:
|
||||||
|
"""Initialize."""
|
||||||
|
super().__init__(entry, data, description)
|
||||||
|
|
||||||
|
self._attr_extra_state_attributes[ATTR_ACTIVITY_TYPE] = (
|
||||||
|
self.entity_description.kind
|
||||||
|
)
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch off.
|
"""Turn the switch off.
|
||||||
|
|
||||||
@ -335,6 +352,19 @@ class RainMachineEnabledSwitch(RainMachineBaseSwitch):
|
|||||||
_attr_icon = "mdi:cog"
|
_attr_icon = "mdi:cog"
|
||||||
entity_description: RainMachineActivitySwitchDescription
|
entity_description: RainMachineActivitySwitchDescription
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
entry: ConfigEntry,
|
||||||
|
data: RainMachineData,
|
||||||
|
description: RainMachineSwitchDescription,
|
||||||
|
) -> None:
|
||||||
|
"""Initialize."""
|
||||||
|
super().__init__(entry, data, description)
|
||||||
|
|
||||||
|
self._attr_extra_state_attributes[ATTR_ACTIVITY_TYPE] = (
|
||||||
|
self.entity_description.kind
|
||||||
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def update_from_latest_data(self) -> None:
|
def update_from_latest_data(self) -> None:
|
||||||
"""Update the entity when new data is received."""
|
"""Update the entity when new data is received."""
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
# name: test_switches[switch.12345_evening-state]
|
# name: test_switches[switch.12345_evening-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'program',
|
||||||
'friendly_name': '12345 Evening',
|
'friendly_name': '12345 Evening',
|
||||||
'icon': 'mdi:water',
|
'icon': 'mdi:water',
|
||||||
'id': 2,
|
'id': 2,
|
||||||
@ -106,6 +107,7 @@
|
|||||||
# name: test_switches[switch.12345_evening_enabled-state]
|
# name: test_switches[switch.12345_evening_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'program',
|
||||||
'friendly_name': '12345 Evening enabled',
|
'friendly_name': '12345 Evening enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -200,6 +202,7 @@
|
|||||||
# name: test_switches[switch.12345_flower_box-state]
|
# name: test_switches[switch.12345_flower_box-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.17,
|
'field_capacity': 0.17,
|
||||||
@ -260,6 +263,7 @@
|
|||||||
# name: test_switches[switch.12345_flower_box_enabled-state]
|
# name: test_switches[switch.12345_flower_box_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Flower box enabled',
|
'friendly_name': '12345 Flower box enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -354,6 +358,7 @@
|
|||||||
# name: test_switches[switch.12345_landscaping-state]
|
# name: test_switches[switch.12345_landscaping-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.17,
|
'field_capacity': 0.17,
|
||||||
@ -414,6 +419,7 @@
|
|||||||
# name: test_switches[switch.12345_landscaping_enabled-state]
|
# name: test_switches[switch.12345_landscaping_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Landscaping enabled',
|
'friendly_name': '12345 Landscaping enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -461,6 +467,7 @@
|
|||||||
# name: test_switches[switch.12345_morning-state]
|
# name: test_switches[switch.12345_morning-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'program',
|
||||||
'friendly_name': '12345 Morning',
|
'friendly_name': '12345 Morning',
|
||||||
'icon': 'mdi:water',
|
'icon': 'mdi:water',
|
||||||
'id': 1,
|
'id': 1,
|
||||||
@ -532,6 +539,7 @@
|
|||||||
# name: test_switches[switch.12345_morning_enabled-state]
|
# name: test_switches[switch.12345_morning_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'program',
|
||||||
'friendly_name': '12345 Morning enabled',
|
'friendly_name': '12345 Morning enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -579,6 +587,7 @@
|
|||||||
# name: test_switches[switch.12345_test-state]
|
# name: test_switches[switch.12345_test-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -639,6 +648,7 @@
|
|||||||
# name: test_switches[switch.12345_test_enabled-state]
|
# name: test_switches[switch.12345_test_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Test enabled',
|
'friendly_name': '12345 Test enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -686,6 +696,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_10-state]
|
# name: test_switches[switch.12345_zone_10-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -746,6 +757,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_10_enabled-state]
|
# name: test_switches[switch.12345_zone_10_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Zone 10 enabled',
|
'friendly_name': '12345 Zone 10 enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -793,6 +805,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_11-state]
|
# name: test_switches[switch.12345_zone_11-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -853,6 +866,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_11_enabled-state]
|
# name: test_switches[switch.12345_zone_11_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Zone 11 enabled',
|
'friendly_name': '12345 Zone 11 enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -900,6 +914,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_12-state]
|
# name: test_switches[switch.12345_zone_12-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -960,6 +975,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_12_enabled-state]
|
# name: test_switches[switch.12345_zone_12_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Zone 12 enabled',
|
'friendly_name': '12345 Zone 12 enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -1007,6 +1023,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_4-state]
|
# name: test_switches[switch.12345_zone_4-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -1067,6 +1084,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_4_enabled-state]
|
# name: test_switches[switch.12345_zone_4_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Zone 4 enabled',
|
'friendly_name': '12345 Zone 4 enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -1114,6 +1132,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_5-state]
|
# name: test_switches[switch.12345_zone_5-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -1174,6 +1193,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_5_enabled-state]
|
# name: test_switches[switch.12345_zone_5_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Zone 5 enabled',
|
'friendly_name': '12345 Zone 5 enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -1221,6 +1241,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_6-state]
|
# name: test_switches[switch.12345_zone_6-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -1281,6 +1302,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_6_enabled-state]
|
# name: test_switches[switch.12345_zone_6_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Zone 6 enabled',
|
'friendly_name': '12345 Zone 6 enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -1328,6 +1350,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_7-state]
|
# name: test_switches[switch.12345_zone_7-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -1388,6 +1411,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_7_enabled-state]
|
# name: test_switches[switch.12345_zone_7_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Zone 7 enabled',
|
'friendly_name': '12345 Zone 7 enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -1435,6 +1459,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_8-state]
|
# name: test_switches[switch.12345_zone_8-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -1495,6 +1520,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_8_enabled-state]
|
# name: test_switches[switch.12345_zone_8_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Zone 8 enabled',
|
'friendly_name': '12345 Zone 8 enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
@ -1542,6 +1568,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_9-state]
|
# name: test_switches[switch.12345_zone_9-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'area': 92.9,
|
'area': 92.9,
|
||||||
'current_cycle': 0,
|
'current_cycle': 0,
|
||||||
'field_capacity': 0.3,
|
'field_capacity': 0.3,
|
||||||
@ -1602,6 +1629,7 @@
|
|||||||
# name: test_switches[switch.12345_zone_9_enabled-state]
|
# name: test_switches[switch.12345_zone_9_enabled-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'activity_type': 'zone',
|
||||||
'friendly_name': '12345 Zone 9 enabled',
|
'friendly_name': '12345 Zone 9 enabled',
|
||||||
'icon': 'mdi:cog',
|
'icon': 'mdi:cog',
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user