Provide a better model for HomeKit service entries (#100848)
parent
fb174f8063
commit
c1b9400833
|
@ -856,8 +856,7 @@ class HomeKit:
|
|||
connection = (dr.CONNECTION_NETWORK_MAC, formatted_mac)
|
||||
identifier = (DOMAIN, self._entry_id, BRIDGE_SERIAL_NUMBER)
|
||||
self._async_purge_old_bridges(dev_reg, identifier, connection)
|
||||
is_accessory_mode = self._homekit_mode == HOMEKIT_MODE_ACCESSORY
|
||||
hk_mode_name = "Accessory" if is_accessory_mode else "Bridge"
|
||||
accessory_type = type(self.driver.accessory).__name__
|
||||
dev_reg.async_get_or_create(
|
||||
config_entry_id=self._entry_id,
|
||||
identifiers={
|
||||
|
@ -866,7 +865,7 @@ class HomeKit:
|
|||
connections={connection},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=accessory_friendly_name(self._entry_title, self.driver.accessory),
|
||||
model=f"HomeKit {hk_mode_name}",
|
||||
model=accessory_type,
|
||||
entry_type=dr.DeviceEntryType.SERVICE,
|
||||
)
|
||||
|
||||
|
|
|
@ -765,6 +765,7 @@ async def test_homekit_start(
|
|||
assert device
|
||||
formatted_mac = dr.format_mac(homekit.driver.state.mac)
|
||||
assert (dr.CONNECTION_NETWORK_MAC, formatted_mac) in device.connections
|
||||
assert device.model == "HomeBridge"
|
||||
|
||||
assert len(device_registry.devices) == 1
|
||||
assert homekit.driver.state.config_version == 1
|
||||
|
@ -2010,6 +2011,16 @@ async def test_homekit_start_in_accessory_mode(
|
|||
assert hk_driver_start.called
|
||||
assert homekit.status == STATUS_RUNNING
|
||||
|
||||
device = device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, entry.entry_id, BRIDGE_SERIAL_NUMBER)}
|
||||
)
|
||||
assert device
|
||||
formatted_mac = dr.format_mac(homekit.driver.state.mac)
|
||||
assert (dr.CONNECTION_NETWORK_MAC, formatted_mac) in device.connections
|
||||
assert device.model == "Light"
|
||||
|
||||
assert len(device_registry.devices) == 1
|
||||
|
||||
|
||||
async def test_homekit_start_in_accessory_mode_unsupported_entity(
|
||||
hass: HomeAssistant,
|
||||
|
|
Loading…
Reference in New Issue