Skip to content

Commit

Permalink
Fix set_variable
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ committed Dec 2, 2021
1 parent 99bb1d1 commit 8aafe67
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions custom_components/hahm/controlunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from homeassistant.const import CONF_DEVICE_ID
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import aiohttp_client, device_registry as dr
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.entity import Entity
from homeassistant.util import slugify
Expand Down Expand Up @@ -366,6 +367,18 @@ def icon(self):

async def set_variable(self, name, value):
"""Set variable value on CCU/Homegear."""
sensor = self._hm_hub.hub_entities.get(name)
if not sensor or name in self.extra_state_attributes:
_LOGGER.error("Variable %s not found on %s", name, self.name)
return

old_value = None
if sensor:
old_value = sensor.state
if old_value is None:
old_value = self.extra_state_attributes.get(name)

value = cv.boolean(value) if isinstance(old_value, bool) else float(value)
await self._hm_hub.set_system_variable(name, value)

@callback
Expand Down

0 comments on commit 8aafe67

Please sign in to comment.