mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
🚑 Fixes Toon doing I/O in coroutines (#21657)
This commit is contained in:
parent
641138a986
commit
73b100d3af
@ -1,6 +1,7 @@
|
||||
"""Support for Toon van Eneco devices."""
|
||||
import logging
|
||||
from typing import Any, Dict
|
||||
from functools import partial
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -48,10 +49,11 @@ async def async_setup_entry(hass: HomeAssistantType,
|
||||
|
||||
conf = hass.data.get(DATA_TOON_CONFIG)
|
||||
|
||||
toon = Toon(entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD],
|
||||
conf[CONF_CLIENT_ID], conf[CONF_CLIENT_SECRET],
|
||||
tenant_id=entry.data[CONF_TENANT],
|
||||
display_common_name=entry.data[CONF_DISPLAY])
|
||||
toon = await hass.async_add_executor_job(partial(
|
||||
Toon, entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD],
|
||||
conf[CONF_CLIENT_ID], conf[CONF_CLIENT_SECRET],
|
||||
tenant_id=entry.data[CONF_TENANT],
|
||||
display_common_name=entry.data[CONF_DISPLAY]))
|
||||
|
||||
hass.data.setdefault(DATA_TOON_CLIENT, {})[entry.entry_id] = toon
|
||||
|
||||
|
@ -102,7 +102,7 @@ class ToonBinarySensor(ToonEntity, BinarySensorDevice):
|
||||
|
||||
return value
|
||||
|
||||
async def async_update(self) -> None:
|
||||
def update(self) -> None:
|
||||
"""Get the latest data from the binary sensor."""
|
||||
section = getattr(self.toon, self.section)
|
||||
self._state = getattr(section, self.measurement)
|
||||
|
@ -117,7 +117,7 @@ class ToonThermostatDevice(ToonDisplayDeviceEntity, ClimateDevice):
|
||||
"""Set new operation mode."""
|
||||
self.toon.thermostat_state = HA_TOON[operation_mode]
|
||||
|
||||
async def async_update(self) -> None:
|
||||
def update(self) -> None:
|
||||
"""Update local state."""
|
||||
if self.toon.thermostat_state is None:
|
||||
self._state = None
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""Config flow to configure the Toon component."""
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -75,11 +76,10 @@ class ToonFlowHandler(config_entries.ConfigFlow):
|
||||
|
||||
app = self.hass.data.get(DATA_TOON_CONFIG, {})
|
||||
try:
|
||||
toon = Toon(user_input[CONF_USERNAME],
|
||||
user_input[CONF_PASSWORD],
|
||||
app[CONF_CLIENT_ID],
|
||||
app[CONF_CLIENT_SECRET],
|
||||
tenant_id=user_input[CONF_TENANT])
|
||||
toon = await self.hass.async_add_executor_job(partial(
|
||||
Toon, user_input[CONF_USERNAME], user_input[CONF_PASSWORD],
|
||||
app[CONF_CLIENT_ID], app[CONF_CLIENT_SECRET],
|
||||
tenant_id=user_input[CONF_TENANT]))
|
||||
|
||||
displays = toon.display_names
|
||||
|
||||
@ -136,12 +136,10 @@ class ToonFlowHandler(config_entries.ConfigFlow):
|
||||
|
||||
app = self.hass.data.get(DATA_TOON_CONFIG, {})
|
||||
try:
|
||||
Toon(self.username,
|
||||
self.password,
|
||||
app[CONF_CLIENT_ID],
|
||||
app[CONF_CLIENT_SECRET],
|
||||
tenant_id=self.tenant,
|
||||
display_common_name=user_input[CONF_DISPLAY])
|
||||
await self.hass.async_add_executor_job(partial(
|
||||
Toon, self.username, self.password, app[CONF_CLIENT_ID],
|
||||
app[CONF_CLIENT_SECRET], tenant_id=self.tenant,
|
||||
display_common_name=user_input[CONF_DISPLAY]))
|
||||
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.exception("Unexpected error while authenticating")
|
||||
|
@ -134,7 +134,7 @@ class ToonSensor(ToonEntity):
|
||||
"""Return the unit this state is expressed in."""
|
||||
return self._unit_of_measurement
|
||||
|
||||
async def async_update(self) -> None:
|
||||
def update(self) -> None:
|
||||
"""Get the latest data from the sensor."""
|
||||
section = getattr(self.toon, self.section)
|
||||
value = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user