1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Add Child Lock Switch to Vesync (#155643)

This commit is contained in:
cdnninja
2025-11-01 13:18:32 -06:00
committed by GitHub
parent 19dee6d22a
commit 83d6a30b2e
4 changed files with 219 additions and 0 deletions

View File

@@ -92,6 +92,9 @@
}
},
"switch": {
"child_lock": {
"name": "Child lock"
},
"display": {
"name": "Display"
}

View File

@@ -56,6 +56,14 @@ SENSOR_DESCRIPTIONS: Final[tuple[VeSyncSwitchEntityDescription, ...]] = (
on_fn=lambda device: device.toggle_display(True),
off_fn=lambda device: device.toggle_display(False),
),
VeSyncSwitchEntityDescription(
key="child_lock",
is_on=lambda device: device.state.child_lock,
exists_fn=(lambda device: rgetattr(device, "state.child_lock") is not None),
translation_key="child_lock",
on_fn=lambda device: device.toggle_child_lock(True),
off_fn=lambda device: device.toggle_child_lock(False),
),
)

View File

@@ -337,6 +337,30 @@
}),
'unit_of_measurement': 'μg/m³',
}),
dict({
'device_class': None,
'disabled': False,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.test_fan_child_lock',
'icon': None,
'name': None,
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock',
'state': dict({
'attributes': dict({
'friendly_name': 'Test Fan Child lock',
}),
'entity_id': 'switch.test_fan_child_lock',
'last_changed': str,
'last_reported': str,
'last_updated': str,
'state': 'unavailable',
}),
'unit_of_measurement': None,
}),
dict({
'device_class': None,
'disabled': False,

View File

@@ -67,8 +67,54 @@
'unique_id': 'air-purifier-display',
'unit_of_measurement': None,
}),
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.air_purifier_131s_child_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock',
'platform': 'vesync',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': 'air-purifier-child_lock',
'unit_of_measurement': None,
}),
])
# ---
# name: test_switch_state[Air Purifier 131s][switch.air_purifier_131s_child_lock]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Air Purifier 131s Child lock',
}),
'context': <ANY>,
'entity_id': 'switch.air_purifier_131s_child_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_state[Air Purifier 131s][switch.air_purifier_131s_display]
StateSnapshot({
'attributes': ReadOnlyDict({
@@ -150,8 +196,54 @@
'unique_id': 'asd_sdfKIHG7IJHGwJGJ7GJ_ag5h3G55-display',
'unit_of_measurement': None,
}),
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.air_purifier_200s_child_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock',
'platform': 'vesync',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': 'asd_sdfKIHG7IJHGwJGJ7GJ_ag5h3G55-child_lock',
'unit_of_measurement': None,
}),
])
# ---
# name: test_switch_state[Air Purifier 200s][switch.air_purifier_200s_child_lock]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Air Purifier 200s Child lock',
}),
'context': <ANY>,
'entity_id': 'switch.air_purifier_200s_child_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_state[Air Purifier 200s][switch.air_purifier_200s_display]
StateSnapshot({
'attributes': ReadOnlyDict({
@@ -233,8 +325,54 @@
'unique_id': '400s-purifier-display',
'unit_of_measurement': None,
}),
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.air_purifier_400s_child_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock',
'platform': 'vesync',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': '400s-purifier-child_lock',
'unit_of_measurement': None,
}),
])
# ---
# name: test_switch_state[Air Purifier 400s][switch.air_purifier_400s_child_lock]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Air Purifier 400s Child lock',
}),
'context': <ANY>,
'entity_id': 'switch.air_purifier_400s_child_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_state[Air Purifier 400s][switch.air_purifier_400s_display]
StateSnapshot({
'attributes': ReadOnlyDict({
@@ -316,8 +454,54 @@
'unique_id': '600s-purifier-display',
'unit_of_measurement': None,
}),
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.air_purifier_600s_child_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock',
'platform': 'vesync',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': '600s-purifier-child_lock',
'unit_of_measurement': None,
}),
])
# ---
# name: test_switch_state[Air Purifier 600s][switch.air_purifier_600s_child_lock]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Air Purifier 600s Child lock',
}),
'context': <ANY>,
'entity_id': 'switch.air_purifier_600s_child_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_state[Air Purifier 600s][switch.air_purifier_600s_display]
StateSnapshot({
'attributes': ReadOnlyDict({