Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pair/unpair buttons for tplink #135847

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions homeassistant/components/tplink/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class TPLinkButtonEntityDescription(
key="tilt_down",
available_fn=lambda dev: dev.is_on,
),
TPLinkButtonEntityDescription(key="pair"),
TPLinkButtonEntityDescription(key="unpair"),
]

BUTTON_DESCRIPTIONS_MAP = {desc.key: desc for desc in BUTTON_DESCRIPTIONS}
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/tplink/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
},
"tilt_down": {
"name": "Tilt down"
},
"pair": {
"name": "Pair new device"
},
"unpair": {
"name": "Unpair device"
}
},
"camera": {
Expand Down
10 changes: 10 additions & 0 deletions tests/components/tplink/fixtures/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,15 @@
"value": 10,
"type": "Number",
"category": "Config"
},
"pair": {
"value": "<Action>",
"type": "Action",
"category": "Config"
},
"unpair": {
"value": "<Action>",
"type": "Action",
"category": "Debug"
}
}
79 changes: 79 additions & 0 deletions tests/components/tplink/snapshots/test_button.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
# serializer version: 1
# name: test_states[button.my_device_pair_new_device-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'button.my_device_pair_new_device',
'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': 'Pair new device',
'platform': 'tplink',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'pair',
'unique_id': '123456789ABCDEFGH_pair',
'unit_of_measurement': None,
})
# ---
# name: test_states[button.my_device_pair_new_device-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'my_device Pair new device',
}),
'context': <ANY>,
'entity_id': 'button.my_device_pair_new_device',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_states[button.my_device_pan_left-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
Expand Down Expand Up @@ -308,6 +354,39 @@
'state': 'unknown',
})
# ---
# name: test_states[button.my_device_unpair_device-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': <RegistryEntryDisabler.INTEGRATION: 'integration'>,
'domain': 'button',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'button.my_device_unpair_device',
'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': 'Unpair device',
'platform': 'tplink',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'unpair',
'unique_id': '123456789ABCDEFGH_unpair',
'unit_of_measurement': None,
})
# ---
# name: test_states[my_device-entry]
DeviceRegistryEntrySnapshot({
'area_id': None,
Expand Down