Add more HomeKit models for discovery (#24391)
* Add more HomeKit models for discovery * Discover Tradfri with HomeKit * Add Wemo device info * Allow full match for HomeKit model * Fix tests
This commit is contained in:
1 parent
b30f4b8fc0
commit
0dc0706eb2
14 files changed
+118
-19
No files matched your search
@@ -13,9 +13,7 @@ from .connection import get_bridge_information, get_accessory_name
|
||||
|
||||
|
||||
HOMEKIT_IGNORE = [
|
||||
'BSB002',
|
||||
'Home Assistant Bridge',
|
||||
'TRADFRI gateway',
|
||||
]
|
||||
HOMEKIT_DIR = '.homekit'
|
||||
PAIRING_FILE = 'pairing.json'
|
||||
|
||||
@@ -175,6 +175,22 @@ class HueFlowHandler(config_entries.ConfigFlow):
|
||||
'path': 'phue-{}.conf'.format(serial)
|
||||
})
|
||||
|
||||
async def async_step_homekit(self, homekit_info):
|
||||
"""Handle HomeKit discovery."""
|
||||
# pylint: disable=unsupported-assignment-operation
|
||||
host = self.context['host'] = homekit_info.get('host')
|
||||
|
||||
if any(host == flow['context']['host']
|
||||
for flow in self._async_in_progress()):
|
||||
return self.async_abort(reason='already_in_progress')
|
||||
|
||||
if host in configured_hosts(self.hass):
|
||||
return self.async_abort(reason='already_configured')
|
||||
|
||||
return await self.async_step_import({
|
||||
'host': host,
|
||||
})
|
||||
|
||||
async def async_step_import(self, import_info):
|
||||
"""Import a new bridge as a config entry.
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
"Royal Philips Electronics"
|
||||
]
|
||||
},
|
||||
"homekit": {
|
||||
"models": [
|
||||
"BSB002"
|
||||
]
|
||||
},
|
||||
"dependencies": [],
|
||||
"codeowners": [
|
||||
"@balloob"
|
||||
|
||||
@@ -87,6 +87,8 @@ class FlowHandler(config_entries.ConfigFlow):
|
||||
self._host = user_input['host']
|
||||
return await self.async_step_auth()
|
||||
|
||||
async_step_homekit = async_step_zeroconf
|
||||
|
||||
async def async_step_import(self, user_input):
|
||||
"""Import a config entry."""
|
||||
for entry in self._async_current_entries():
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
"requirements": [
|
||||
"pytradfri[async]==6.0.1"
|
||||
],
|
||||
"homekit": {
|
||||
"models": [
|
||||
"TRADFRI"
|
||||
]
|
||||
},
|
||||
"dependencies": [],
|
||||
"zeroconf": ["_coap._udp.local."],
|
||||
"codeowners": [
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
"Belkin International Inc."
|
||||
]
|
||||
},
|
||||
"homekit": {
|
||||
"models": [
|
||||
"Wemo"
|
||||
]
|
||||
},
|
||||
"dependencies": [],
|
||||
"codeowners": [
|
||||
"@sqldiablo"
|
||||
|
||||
@@ -12,7 +12,7 @@ from homeassistant.util import convert
|
||||
from homeassistant.const import (
|
||||
STATE_OFF, STATE_ON, STATE_STANDBY, STATE_UNKNOWN)
|
||||
|
||||
from . import SUBSCRIPTION_REGISTRY
|
||||
from . import SUBSCRIPTION_REGISTRY, DOMAIN as WEMO_DOMAIN
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=10)
|
||||
|
||||
@@ -93,6 +93,14 @@ class WemoSwitch(SwitchDevice):
|
||||
"""Return the name of the switch if any."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return the device info."""
|
||||
return {
|
||||
'name': self._name,
|
||||
'identifiers': {(WEMO_DOMAIN, self._serialnumber)},
|
||||
}
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes of the device."""
|
||||
|
||||
@@ -112,7 +112,7 @@ def handle_homekit(hass, info) -> bool:
|
||||
return False
|
||||
|
||||
for test_model in HOMEKIT:
|
||||
if not model.startswith(test_model):
|
||||
if model != test_model and not model.startswith(test_model + " "):
|
||||
continue
|
||||
|
||||
hass.add_job(
|
||||
|
||||
Reference in new issue
Block a user