Adapt Axis integration to async HTTPx calls (#42095)

This commit is contained in:
Robert Svensson authored and GitHub committed 2020-10-20 09:31:04 +02:00
1 parent fcdb54d878
commit 1303d20064
9 files changed
+41 -40

No files matched your search

+5 -6
View File
@@ -161,9 +161,7 @@ class AxisNetworkDevice:
async def use_mqtt(self, hass: HomeAssistant, component: str) -> None:
"""Set up to use MQTT."""
try:
status = await hass.async_add_executor_job(
self.api.vapix.mqtt.get_client_status
)
status = await self.api.vapix.mqtt.get_client_status()
except Unauthorized:
# This means the user has too low privileges
status = {}
@@ -238,14 +236,15 @@ class AxisNetworkDevice:
)
self.api.stream.stop()
@callback
def shutdown(self, event):
async def shutdown(self, event):
"""Stop the event stream."""
self.disconnect_from_stream()
await self.api.vapix.close()
async def async_reset(self):
"""Reset this device to default state."""
self.disconnect_from_stream()
await self.api.vapix.close()
unload_ok = all(
await asyncio.gather(
@@ -275,7 +274,7 @@ async def get_device(hass, host, port, username, password):
try:
with async_timeout.timeout(15):
await hass.async_add_executor_job(device.vapix.initialize)
await device.vapix.initialize()
return device