Skip to content

Commit

Permalink
Add motion sensor setting to tplink (home-assistant#129393)
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti authored Nov 6, 2024
1 parent 27e81fe commit c6cb288
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
6 changes: 6 additions & 0 deletions homeassistant/components/tplink/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
},
"child_lock": {
"default": "mdi:account-lock"
},
"pir_enabled": {
"default": "mdi:motion-sensor-off",
"state": {
"on": "mdi:motion-sensor"
}
}
},
"sensor": {
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/tplink/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@
},
"child_lock": {
"name": "Child lock"
},
"pir_enabled": {
"name": "Motion sensor"
}
},
"number": {
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/tplink/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class TPLinkSwitchEntityDescription(
TPLinkSwitchEntityDescription(
key="child_lock",
),
TPLinkSwitchEntityDescription(
key="pir_enabled",
),
)

SWITCH_DESCRIPTIONS_MAP = {desc.key: desc for desc in SWITCH_DESCRIPTIONS}
Expand Down
5 changes: 5 additions & 0 deletions tests/components/tplink/fixtures/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"type": "Switch",
"category": "Config"
},
"pir_enabled": {
"value": true,
"type": "Switch",
"category": "Config"
},
"current_consumption": {
"value": 5.23,
"type": "Sensor",
Expand Down
46 changes: 46 additions & 0 deletions tests/components/tplink/snapshots/test_switch.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,52 @@
'state': 'on',
})
# ---
# name: test_states[switch.my_device_motion_sensor-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': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.my_device_motion_sensor',
'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 sensor',
'platform': 'tplink',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'pir_enabled',
'unique_id': '123456789ABCDEFGH_pir_enabled',
'unit_of_measurement': None,
})
# ---
# name: test_states[switch.my_device_motion_sensor-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'my_device Motion sensor',
}),
'context': <ANY>,
'entity_id': 'switch.my_device_motion_sensor',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_states[switch.my_device_smooth_transitions-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
Expand Down

0 comments on commit c6cb288

Please sign in to comment.