Fix callback and async (#31281)
* Fix callback and async * Fix a return * Fix test * Fix mqtt tests * Fix some more callbacks
This commit is contained in:
1 parent
ee602e40a6
commit
e9e44dbd97
90 files changed
+627
-883
No files matched your search
@@ -2,6 +2,7 @@
|
||||
from homekit.model.characteristics import CharacteristicsTypes
|
||||
|
||||
from homeassistant.components.air_quality import AirQualityEntity
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -83,6 +84,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
if service["stype"] != "air-quality":
|
||||
return False
|
||||
|
||||
@@ -17,6 +17,7 @@ from homeassistant.const import (
|
||||
STATE_ALARM_DISARMED,
|
||||
STATE_ALARM_TRIGGERED,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -45,6 +46,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
if service["stype"] != "security-system":
|
||||
return False
|
||||
|
||||
@@ -7,6 +7,7 @@ from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_SMOKE,
|
||||
BinarySensorDevice,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -98,6 +99,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
entity_class = ENTITY_TYPES.get(service["stype"])
|
||||
if not entity_class:
|
||||
|
||||
@@ -20,6 +20,7 @@ from homeassistant.components.climate.const import (
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -50,6 +51,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
if service["stype"] != "thermostat":
|
||||
return False
|
||||
|
||||
@@ -12,6 +12,7 @@ from homekit.exceptions import (
|
||||
from homekit.model.characteristics import CharacteristicsTypes
|
||||
from homekit.model.services import ServicesTypes
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
|
||||
from .const import DOMAIN, ENTITY_MAP, HOMEKIT_ACCESSORY_DISPATCH
|
||||
@@ -116,6 +117,7 @@ class HKDevice:
|
||||
char for char in self.pollable_characteristics if char[0] != accessory_id
|
||||
]
|
||||
|
||||
@callback
|
||||
def async_set_unavailable(self):
|
||||
"""Mark state of all entities on this connection as unavailable."""
|
||||
self.available = False
|
||||
|
||||
@@ -16,6 +16,7 @@ from homeassistant.components.cover import (
|
||||
CoverDevice,
|
||||
)
|
||||
from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -41,6 +42,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
info = {"aid": aid, "iid": service["iid"]}
|
||||
if service["stype"] == "garage-door-opener":
|
||||
|
||||
@@ -15,6 +15,7 @@ from homeassistant.components.fan import (
|
||||
SUPPORT_SET_SPEED,
|
||||
FanEntity,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -235,6 +236,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
entity_class = ENTITY_TYPES.get(service["stype"])
|
||||
if not entity_class:
|
||||
|
||||
@@ -12,6 +12,7 @@ from homeassistant.components.light import (
|
||||
SUPPORT_COLOR_TEMP,
|
||||
Light,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -23,6 +24,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
if service["stype"] != "lightbulb":
|
||||
return False
|
||||
|
||||
@@ -5,6 +5,7 @@ from homekit.model.characteristics import CharacteristicsTypes
|
||||
|
||||
from homeassistant.components.lock import LockDevice
|
||||
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_LOCKED, STATE_UNLOCKED
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -22,6 +23,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
if service["stype"] != "lock-mechanism":
|
||||
return False
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
from homekit.model.characteristics import CharacteristicsTypes
|
||||
|
||||
from homeassistant.const import DEVICE_CLASS_BATTERY, TEMP_CELSIUS
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -246,6 +247,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
entity_class = ENTITY_TYPES.get(service["stype"])
|
||||
if not entity_class:
|
||||
|
||||
@@ -45,6 +45,7 @@ class EntityMapStorage:
|
||||
"""Get a pairing cache item."""
|
||||
return self.storage_data.get(homekit_id)
|
||||
|
||||
@callback
|
||||
def async_create_or_update_map(self, homekit_id, config_num, accessories):
|
||||
"""Create a new pairing cache."""
|
||||
data = {"config_num": config_num, "accessories": accessories}
|
||||
@@ -52,6 +53,7 @@ class EntityMapStorage:
|
||||
self._async_schedule_save()
|
||||
return data
|
||||
|
||||
@callback
|
||||
def async_delete_map(self, homekit_id):
|
||||
"""Delete pairing cache."""
|
||||
if homekit_id not in self.storage_data:
|
||||
|
||||
@@ -4,6 +4,7 @@ import logging
|
||||
from homekit.model.characteristics import CharacteristicsTypes
|
||||
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import KNOWN_DEVICES, HomeKitEntity
|
||||
|
||||
@@ -17,6 +18,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_service(aid, service):
|
||||
if service["stype"] not in ("switch", "outlet"):
|
||||
return False
|
||||
|
||||
Reference in new issue
Block a user