Add detection switches to tplink integration (#133828)

pull/133510/merge
Steven B. 2024-12-22 22:54:44 +00:00 committed by GitHub
parent 4ed0c21a4a
commit 8ab936b87c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 252 additions and 0 deletions

View File

@ -89,6 +89,30 @@
"state": {
"on": "mdi:motion-sensor"
}
},
"motion_detection": {
"default": "mdi:motion-sensor-off",
"state": {
"on": "mdi:motion-sensor"
}
},
"person_detection": {
"default": "mdi:account-off",
"state": {
"on": "mdi:account"
}
},
"tamper_detection": {
"default": "mdi:shield-off",
"state": {
"on": "mdi:shield"
}
},
"baby_cry_detection": {
"default": "mdi:baby-face-outline",
"state": {
"on": "mdi:baby-face"
}
}
},
"sensor": {

View File

@ -233,6 +233,18 @@
},
"pir_enabled": {
"name": "Motion sensor"
},
"motion_detection": {
"name": "Motion detection"
},
"person_detection": {
"name": "Person detection"
},
"tamper_detection": {
"name": "Tamper detection"
},
"baby_cry_detection": {
"name": "Baby cry detection"
}
},
"number": {

View File

@ -54,6 +54,18 @@ SWITCH_DESCRIPTIONS: tuple[TPLinkSwitchEntityDescription, ...] = (
TPLinkSwitchEntityDescription(
key="pir_enabled",
),
TPLinkSwitchEntityDescription(
key="motion_detection",
),
TPLinkSwitchEntityDescription(
key="person_detection",
),
TPLinkSwitchEntityDescription(
key="tamper_detection",
),
TPLinkSwitchEntityDescription(
key="baby_cry_detection",
),
)
SWITCH_DESCRIPTIONS_MAP = {desc.key: desc for desc in SWITCH_DESCRIPTIONS}

View File

@ -44,6 +44,26 @@
"type": "Switch",
"category": "Config"
},
"motion_detection": {
"value": true,
"type": "Switch",
"category": "Primary"
},
"person_detection": {
"value": true,
"type": "Switch",
"category": "Primary"
},
"tamper_detection": {
"value": true,
"type": "Switch",
"category": "Primary"
},
"baby_cry_detection": {
"value": true,
"type": "Switch",
"category": "Primary"
},
"current_consumption": {
"value": 5.23,
"type": "Sensor",

View File

@ -173,6 +173,52 @@
'state': 'on',
})
# ---
# name: test_states[switch.my_device_baby_cry_detection-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.my_device_baby_cry_detection',
'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': 'Baby cry detection',
'platform': 'tplink',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'baby_cry_detection',
'unique_id': '123456789ABCDEFGH_baby_cry_detection',
'unit_of_measurement': None,
})
# ---
# name: test_states[switch.my_device_baby_cry_detection-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'my_device Baby cry detection',
}),
'context': <ANY>,
'entity_id': 'switch.my_device_baby_cry_detection',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_states[switch.my_device_child_lock-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@ -311,6 +357,52 @@
'state': 'on',
})
# ---
# name: test_states[switch.my_device_motion_detection-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.my_device_motion_detection',
'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': 'Motion detection',
'platform': 'tplink',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'motion_detection',
'unique_id': '123456789ABCDEFGH_motion_detection',
'unit_of_measurement': None,
})
# ---
# name: test_states[switch.my_device_motion_detection-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'my_device Motion detection',
}),
'context': <ANY>,
'entity_id': 'switch.my_device_motion_detection',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_states[switch.my_device_motion_sensor-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@ -357,6 +449,52 @@
'state': 'on',
})
# ---
# name: test_states[switch.my_device_person_detection-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.my_device_person_detection',
'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': 'Person detection',
'platform': 'tplink',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'person_detection',
'unique_id': '123456789ABCDEFGH_person_detection',
'unit_of_measurement': None,
})
# ---
# name: test_states[switch.my_device_person_detection-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'my_device Person detection',
}),
'context': <ANY>,
'entity_id': 'switch.my_device_person_detection',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_states[switch.my_device_smooth_transitions-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@ -403,3 +541,49 @@
'state': 'on',
})
# ---
# name: test_states[switch.my_device_tamper_detection-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.my_device_tamper_detection',
'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': 'Tamper detection',
'platform': 'tplink',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'tamper_detection',
'unique_id': '123456789ABCDEFGH_tamper_detection',
'unit_of_measurement': None,
})
# ---
# name: test_states[switch.my_device_tamper_detection-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'my_device Tamper detection',
}),
'context': <ANY>,
'entity_id': 'switch.my_device_tamper_detection',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---