Skip to content

Commit

Permalink
Bump HAP-python to 4.1.0 (home-assistant#55005)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Aug 23, 2021
1 parent a5c1fbc commit 99465f5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
6 changes: 1 addition & 5 deletions homeassistant/components/homekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,6 @@ def setup(self, async_zeroconf_instance):
# as pyhap uses a random one until state is restored
if os.path.exists(persist_file):
self.driver.load()
self.driver.state.config_version += 1
if self.driver.state.config_version > 65535:
self.driver.state.config_version = 1

self.driver.persist()

async def async_reset_accessories(self, entity_ids):
"""Reset the accessory to load the latest configuration."""
Expand Down Expand Up @@ -688,6 +683,7 @@ async def async_start(self, *args):
self._async_register_bridge()
_LOGGER.debug("Driver start for %s", self._name)
await self.driver.async_start()
self.driver.async_persist()
self.status = STATUS_RUNNING

if self.driver.state.paired:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/homekit/accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,9 @@ def __init__(self, hass, entry_id, bridge_name, entry_title, **kwargs):
self._bridge_name = bridge_name
self._entry_title = entry_title

def pair(self, client_uuid, client_public):
def pair(self, client_uuid, client_public, client_permissions):
"""Override super function to dismiss setup message if paired."""
success = super().pair(client_uuid, client_public)
success = super().pair(client_uuid, client_public, client_permissions)
if success:
dismiss_setup_message(self.hass, self._entry_id)
return success
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "HomeKit",
"documentation": "https://www.home-assistant.io/integrations/homekit",
"requirements": [
"HAP-python==4.0.0",
"HAP-python==4.1.0",
"fnvhash==0.1.0",
"PyQRCode==1.2.1",
"base36==0.1.1"
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Adafruit-SHT31==1.0.2
# Adafruit_BBIO==1.1.1

# homeassistant.components.homekit
HAP-python==4.0.0
HAP-python==4.1.0

# homeassistant.components.mastodon
Mastodon.py==1.5.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
AEMET-OpenData==0.2.1

# homeassistant.components.homekit
HAP-python==4.0.0
HAP-python==4.1.0

# homeassistant.components.flick_electric
PyFlick==0.0.2
Expand Down
4 changes: 2 additions & 2 deletions tests/components/homekit/test_accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,9 @@ def test_home_driver():
with patch("pyhap.accessory_driver.AccessoryDriver.pair") as mock_pair, patch(
"homeassistant.components.homekit.accessories.dismiss_setup_message"
) as mock_dissmiss_msg:
driver.pair("client_uuid", "client_public")
driver.pair("client_uuid", "client_public", b"1")

mock_pair.assert_called_with("client_uuid", "client_public")
mock_pair.assert_called_with("client_uuid", "client_public", b"1")
mock_dissmiss_msg.assert_called_with("hass", "entry_id")

# unpair
Expand Down
8 changes: 4 additions & 4 deletions tests/components/homekit/test_homekit.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ async def test_homekit_start(hass, hk_driver, mock_zeroconf, device_reg):
assert (device_registry.CONNECTION_NETWORK_MAC, formatted_mac) in device.connections

assert len(device_reg.devices) == 1
assert homekit.driver.state.config_version == 2
assert homekit.driver.state.config_version == 1


async def test_homekit_start_with_a_broken_accessory(hass, hk_driver, mock_zeroconf):
Expand Down Expand Up @@ -695,7 +695,7 @@ async def test_homekit_unpair(hass, device_reg, mock_zeroconf):
homekit.status = STATUS_RUNNING

state = homekit.driver.state
state.paired_clients = {"client1": "any"}
state.add_paired_client("client1", "any", b"1")
formatted_mac = device_registry.format_mac(state.mac)
hk_bridge_dev = device_reg.async_get_device(
{}, {(device_registry.CONNECTION_NETWORK_MAC, formatted_mac)}
Expand Down Expand Up @@ -734,7 +734,7 @@ async def test_homekit_unpair_missing_device_id(hass, device_reg, mock_zeroconf)
homekit.status = STATUS_RUNNING

state = homekit.driver.state
state.paired_clients = {"client1": "any"}
state.add_paired_client("client1", "any", b"1")
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
DOMAIN,
Expand Down Expand Up @@ -780,7 +780,7 @@ async def test_homekit_unpair_not_homekit_device(hass, device_reg, mock_zeroconf
)

state = homekit.driver.state
state.paired_clients = {"client1": "any"}
state.add_paired_client("client1", "any", b"1")
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
DOMAIN,
Expand Down

0 comments on commit 99465f5

Please sign in to comment.