Upgrade vallox to async client API (#24774)
parent
06af6f19a3
commit
56b8da133c
|
@ -96,7 +96,7 @@ async def async_setup(hass, config):
|
||||||
|
|
||||||
client = Vallox(host)
|
client = Vallox(host)
|
||||||
state_proxy = ValloxStateProxy(hass, client)
|
state_proxy = ValloxStateProxy(hass, client)
|
||||||
service_handler = ValloxServiceHandler(hass, client, state_proxy)
|
service_handler = ValloxServiceHandler(client, state_proxy)
|
||||||
|
|
||||||
hass.data[DOMAIN] = {
|
hass.data[DOMAIN] = {
|
||||||
'client': client,
|
'client': client,
|
||||||
|
@ -160,10 +160,8 @@ class ValloxStateProxy:
|
||||||
_LOGGER.debug("Updating Vallox state cache")
|
_LOGGER.debug("Updating Vallox state cache")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._metric_cache = await self._hass.async_add_executor_job(
|
self._metric_cache = await self._client.fetch_metrics()
|
||||||
self._client.fetch_metrics)
|
self._profile = await self._client.get_profile()
|
||||||
self._profile = await self._hass.async_add_executor_job(
|
|
||||||
self._client.get_profile)
|
|
||||||
self._valid = True
|
self._valid = True
|
||||||
|
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
|
@ -176,9 +174,8 @@ class ValloxStateProxy:
|
||||||
class ValloxServiceHandler:
|
class ValloxServiceHandler:
|
||||||
"""Services implementation."""
|
"""Services implementation."""
|
||||||
|
|
||||||
def __init__(self, hass, client, state_proxy):
|
def __init__(self, client, state_proxy):
|
||||||
"""Initialize the proxy."""
|
"""Initialize the proxy."""
|
||||||
self._hass = hass
|
|
||||||
self._client = client
|
self._client = client
|
||||||
self._state_proxy = state_proxy
|
self._state_proxy = state_proxy
|
||||||
|
|
||||||
|
@ -187,8 +184,7 @@ class ValloxServiceHandler:
|
||||||
_LOGGER.debug("Setting ventilation profile to: %s", profile)
|
_LOGGER.debug("Setting ventilation profile to: %s", profile)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self._hass.async_add_executor_job(
|
await self._client.set_profile(STR_TO_PROFILE[profile])
|
||||||
self._client.set_profile, STR_TO_PROFILE[profile])
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
|
@ -201,8 +197,7 @@ class ValloxServiceHandler:
|
||||||
_LOGGER.debug("Setting Home fan speed to: %d%%", fan_speed)
|
_LOGGER.debug("Setting Home fan speed to: %d%%", fan_speed)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self._hass.async_add_executor_job(
|
await self._client.set_values(
|
||||||
self._client.set_values,
|
|
||||||
{METRIC_KEY_PROFILE_FAN_SPEED_HOME: fan_speed})
|
{METRIC_KEY_PROFILE_FAN_SPEED_HOME: fan_speed})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -216,8 +211,7 @@ class ValloxServiceHandler:
|
||||||
_LOGGER.debug("Setting Away fan speed to: %d%%", fan_speed)
|
_LOGGER.debug("Setting Away fan speed to: %d%%", fan_speed)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self._hass.async_add_executor_job(
|
await self._client.set_values(
|
||||||
self._client.set_values,
|
|
||||||
{METRIC_KEY_PROFILE_FAN_SPEED_AWAY: fan_speed})
|
{METRIC_KEY_PROFILE_FAN_SPEED_AWAY: fan_speed})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -231,8 +225,7 @@ class ValloxServiceHandler:
|
||||||
_LOGGER.debug("Setting Boost fan speed to: %d%%", fan_speed)
|
_LOGGER.debug("Setting Boost fan speed to: %d%%", fan_speed)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self._hass.async_add_executor_job(
|
await self._client.set_values(
|
||||||
self._client.set_values,
|
|
||||||
{METRIC_KEY_PROFILE_FAN_SPEED_BOOST: fan_speed})
|
{METRIC_KEY_PROFILE_FAN_SPEED_BOOST: fan_speed})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,7 @@ async def async_setup_platform(hass, config, async_add_entities,
|
||||||
|
|
||||||
client = hass.data[DOMAIN]['client']
|
client = hass.data[DOMAIN]['client']
|
||||||
|
|
||||||
await hass.async_add_executor_job(
|
client.set_settable_address(METRIC_KEY_MODE, int)
|
||||||
client.set_settable_address, METRIC_KEY_MODE, int)
|
|
||||||
|
|
||||||
device = ValloxFan(hass.data[DOMAIN]['name'],
|
device = ValloxFan(hass.data[DOMAIN]['name'],
|
||||||
client,
|
client,
|
||||||
|
@ -134,8 +133,7 @@ class ValloxFan(FanEntity):
|
||||||
|
|
||||||
if self._state is False:
|
if self._state is False:
|
||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(
|
await self._client.set_values({METRIC_KEY_MODE: 0})
|
||||||
self._client.set_values, {METRIC_KEY_MODE: 0})
|
|
||||||
|
|
||||||
# This state change affects other entities like sensors. Force
|
# This state change affects other entities like sensors. Force
|
||||||
# an immediate update that can be observed by all parties
|
# an immediate update that can be observed by all parties
|
||||||
|
@ -152,8 +150,7 @@ class ValloxFan(FanEntity):
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
if self._state is True:
|
if self._state is True:
|
||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(
|
await self._client.set_values({METRIC_KEY_MODE: 5})
|
||||||
self._client.set_values, {METRIC_KEY_MODE: 5})
|
|
||||||
|
|
||||||
# Same as for turn_on method.
|
# Same as for turn_on method.
|
||||||
await self._state_proxy.async_update(None)
|
await self._state_proxy.async_update(None)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "Vallox",
|
"name": "Vallox",
|
||||||
"documentation": "https://www.home-assistant.io/components/vallox",
|
"documentation": "https://www.home-assistant.io/components/vallox",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"vallox-websocket-api==1.5.2"
|
"vallox-websocket-api==2.0.0"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": []
|
"codeowners": []
|
||||||
|
|
|
@ -1829,7 +1829,7 @@ uscisstatus==0.1.1
|
||||||
uvcclient==0.11.0
|
uvcclient==0.11.0
|
||||||
|
|
||||||
# homeassistant.components.vallox
|
# homeassistant.components.vallox
|
||||||
vallox-websocket-api==1.5.2
|
vallox-websocket-api==2.0.0
|
||||||
|
|
||||||
# homeassistant.components.venstar
|
# homeassistant.components.venstar
|
||||||
venstarcolortouch==0.7
|
venstarcolortouch==0.7
|
||||||
|
|
Loading…
Reference in New Issue