mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Mark homekit accessories unavailable if the underlying entity is unavailable (#35685)
* Mark homekit accessories unavailable if the underlying entity is unavailable. * bump pyhap to 2.9.0 * bump hap * Update homeassistant/components/homekit/accessories.py Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
141c4c2f33
commit
1c663dc179
@ -25,6 +25,7 @@ from homeassistant.const import (
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
STATE_ON,
|
||||
STATE_UNAVAILABLE,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_PERCENTAGE,
|
||||
@ -322,6 +323,12 @@ class HomeAccessory(Accessory):
|
||||
CHAR_STATUS_LOW_BATTERY, value=0
|
||||
)
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return if accessory is available."""
|
||||
state = self.hass.states.get(self.entity_id)
|
||||
return state is not None and state.state != STATE_UNAVAILABLE
|
||||
|
||||
async def run(self):
|
||||
"""Handle accessory driver started event.
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
"domain": "homekit",
|
||||
"name": "HomeKit",
|
||||
"documentation": "https://www.home-assistant.io/integrations/homekit",
|
||||
"requirements": ["HAP-python==2.8.4","fnvhash==0.1.0","PyQRCode==1.2.1","base36==0.1.1","PyTurboJPEG==1.4.0"],
|
||||
"requirements": ["HAP-python==2.9.1","fnvhash==0.1.0","PyQRCode==1.2.1","base36==0.1.1","PyTurboJPEG==1.4.0"],
|
||||
"dependencies": ["http", "camera", "ffmpeg"],
|
||||
"after_dependencies": ["logbook", "zeroconf"],
|
||||
"codeowners": ["@bdraco"],
|
||||
|
@ -35,7 +35,7 @@ Adafruit-SHT31==1.0.2
|
||||
# Adafruit_BBIO==1.1.1
|
||||
|
||||
# homeassistant.components.homekit
|
||||
HAP-python==2.8.4
|
||||
HAP-python==2.9.1
|
||||
|
||||
# homeassistant.components.mastodon
|
||||
Mastodon.py==1.5.1
|
||||
|
@ -4,7 +4,7 @@
|
||||
-r requirements_test.txt
|
||||
|
||||
# homeassistant.components.homekit
|
||||
HAP-python==2.8.4
|
||||
HAP-python==2.9.1
|
||||
|
||||
# homeassistant.components.plugwise
|
||||
Plugwise_Smile==0.2.10
|
||||
|
@ -42,6 +42,7 @@ from homeassistant.const import (
|
||||
EVENT_TIME_CHANGED,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
STATE_UNAVAILABLE,
|
||||
__version__,
|
||||
)
|
||||
import homeassistant.util.dt as dt_util
|
||||
@ -88,7 +89,7 @@ async def test_home_accessory(hass, hk_driver):
|
||||
entity_id2 = "light.accessory"
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
hass.states.async_set(entity_id2, None)
|
||||
hass.states.async_set(entity_id2, STATE_UNAVAILABLE)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@ -98,6 +99,7 @@ async def test_home_accessory(hass, hk_driver):
|
||||
assert acc.hass == hass
|
||||
assert acc.display_name == "Home Accessory"
|
||||
assert acc.aid == 2
|
||||
assert acc.available is True
|
||||
assert acc.category == 1 # Category.OTHER
|
||||
assert len(acc.services) == 1
|
||||
serv = acc.services[0] # SERV_ACCESSORY_INFO
|
||||
@ -127,6 +129,7 @@ async def test_home_accessory(hass, hk_driver):
|
||||
ATTR_INTERGRATION: "luxe",
|
||||
},
|
||||
)
|
||||
assert acc3.available is False
|
||||
serv = acc3.services[0] # SERV_ACCESSORY_INFO
|
||||
assert serv.get_characteristic(CHAR_NAME).value == "Home Accessory"
|
||||
assert serv.get_characteristic(CHAR_MANUFACTURER).value == "Lux Brands"
|
||||
|
Loading…
x
Reference in New Issue
Block a user