mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Change variable to poll for ccu/homegear (#2987)
This commit is contained in:
parent
95b98f6752
commit
d2bb61ad9e
@ -27,9 +27,9 @@ REQUIREMENTS = ["pyhomematic==0.1.13"]
|
|||||||
|
|
||||||
HOMEMATIC = None
|
HOMEMATIC = None
|
||||||
HOMEMATIC_LINK_DELAY = 0.5
|
HOMEMATIC_LINK_DELAY = 0.5
|
||||||
HOMEMATIC_VAR = {}
|
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATE_HUB = timedelta(seconds=300)
|
MIN_TIME_BETWEEN_UPDATE_HUB = timedelta(seconds=300)
|
||||||
|
MIN_TIME_BETWEEN_UPDATE_VAR = timedelta(seconds=60)
|
||||||
|
|
||||||
DISCOVER_SWITCHES = 'homematic.switch'
|
DISCOVER_SWITCHES = 'homematic.switch'
|
||||||
DISCOVER_LIGHTS = 'homematic.light'
|
DISCOVER_LIGHTS = 'homematic.light'
|
||||||
@ -141,7 +141,7 @@ SCHEMA_SERVICE_VIRTUALKEY = vol.Schema({
|
|||||||
|
|
||||||
SCHEMA_SERVICE_SET_VALUE = vol.Schema({
|
SCHEMA_SERVICE_SET_VALUE = vol.Schema({
|
||||||
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
|
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
vol.Required(ATTR_VALUE): vol.Coerce(float),
|
vol.Required(ATTR_VALUE): cv.match_all,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -193,7 +193,6 @@ def setup(hass, config):
|
|||||||
localport=local_port,
|
localport=local_port,
|
||||||
remote=remote_ip,
|
remote=remote_ip,
|
||||||
remoteport=remote_port,
|
remoteport=remote_port,
|
||||||
eventcallback=_event_callback_handler,
|
|
||||||
systemcallback=bound_system_callback,
|
systemcallback=bound_system_callback,
|
||||||
resolvenames=resolvenames,
|
resolvenames=resolvenames,
|
||||||
rpcusername=username,
|
rpcusername=username,
|
||||||
@ -223,9 +222,7 @@ def setup(hass, config):
|
|||||||
variables = HOMEMATIC.getAllSystemVariables()
|
variables = HOMEMATIC.getAllSystemVariables()
|
||||||
if variables is not None:
|
if variables is not None:
|
||||||
for key, value in variables.items():
|
for key, value in variables.items():
|
||||||
hm_var = HMVariable(key, value)
|
entities.append(HMVariable(key, value))
|
||||||
HOMEMATIC_VAR.update({key: hm_var})
|
|
||||||
entities.append(hm_var)
|
|
||||||
|
|
||||||
# add homematic entites
|
# add homematic entites
|
||||||
entities.append(HMHub())
|
entities.append(HMHub())
|
||||||
@ -233,7 +230,7 @@ def setup(hass, config):
|
|||||||
|
|
||||||
##
|
##
|
||||||
# register set_value service if exists variables
|
# register set_value service if exists variables
|
||||||
if not HOMEMATIC_VAR:
|
if not variables:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _service_handle_value(service):
|
def _service_handle_value(service):
|
||||||
@ -253,13 +250,6 @@ def setup(hass, config):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _event_callback_handler(interface_id, address, value_key, value):
|
|
||||||
"""Callback handler for events."""
|
|
||||||
if not address:
|
|
||||||
if value_key in HOMEMATIC_VAR:
|
|
||||||
HOMEMATIC_VAR[value_key].hm_update(value)
|
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-many-branches
|
# pylint: disable=too-many-branches
|
||||||
def _system_callback_handler(hass, config, src, *args):
|
def _system_callback_handler(hass, config, src, *args):
|
||||||
"""Callback handler."""
|
"""Callback handler."""
|
||||||
@ -567,23 +557,23 @@ class HMVariable(Entity):
|
|||||||
"""Return the icon to use in the frontend, if any."""
|
"""Return the icon to use in the frontend, if any."""
|
||||||
return "mdi:code-string"
|
return "mdi:code-string"
|
||||||
|
|
||||||
@property
|
@Throttle(MIN_TIME_BETWEEN_UPDATE_VAR)
|
||||||
def should_poll(self):
|
def update(self):
|
||||||
"""Return false. Homematic states are pushed by the XML RPC Server."""
|
"""Retrieve latest state."""
|
||||||
return False
|
if HOMEMATIC is None:
|
||||||
|
return
|
||||||
def hm_update(self, value):
|
self._state = HOMEMATIC.getSystemVariable(self._name)
|
||||||
"""Update variable value from event callback."""
|
|
||||||
self._state = value
|
|
||||||
self.update_ha_state()
|
|
||||||
|
|
||||||
def hm_set(self, value):
|
def hm_set(self, value):
|
||||||
"""Set variable on homematic controller."""
|
"""Set variable on homematic controller."""
|
||||||
if HOMEMATIC is not None:
|
if HOMEMATIC is not None:
|
||||||
|
if isinstance(self._state, bool):
|
||||||
|
value = cv.boolean(value)
|
||||||
|
else:
|
||||||
|
value = float(value)
|
||||||
HOMEMATIC.setSystemVariable(self._name, value)
|
HOMEMATIC.setSystemVariable(self._name, value)
|
||||||
|
self._state = value
|
||||||
# CCU don't send variable updates from own
|
self.update_ha_state()
|
||||||
self.hm_update(value)
|
|
||||||
|
|
||||||
|
|
||||||
class HMDevice(Entity):
|
class HMDevice(Entity):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user