Add haa vendor extensions (#59750)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Jared Hobbs 2021-11-20 08:22:10 -07:00 committed by GitHub
parent 70990ebf81
commit 6d4b74f8f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 171 additions and 4 deletions

View file

@ -0,0 +1,45 @@
"""Basic checks for HomeKit button."""
from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
from tests.components.homekit_controller.common import Helper, setup_test_component
def create_switch_with_setup_button(accessory):
"""Define setup button characteristics."""
service = accessory.add_service(ServicesTypes.OUTLET)
setup = service.add_char(CharacteristicsTypes.Vendor.HAA_SETUP)
setup.value = ""
setup.format = "string"
cur_state = service.add_char(CharacteristicsTypes.ON)
cur_state.value = True
return service
async def test_press_button(hass):
"""Test a switch service that has a button characteristic is correctly handled."""
helper = await setup_test_component(hass, create_switch_with_setup_button)
# Helper will be for the primary entity, which is the outlet. Make a helper for the button.
energy_helper = Helper(
hass,
"button.testdevice_setup",
helper.pairing,
helper.accessory,
helper.config_entry,
)
outlet = energy_helper.accessory.services.first(service_type=ServicesTypes.OUTLET)
setup = outlet[CharacteristicsTypes.Vendor.HAA_SETUP]
await hass.services.async_call(
"button",
"press",
{"entity_id": "button.testdevice_setup"},
blocking=True,
)
assert setup.value == "#HAA@trcmd"