Update detecting lost connections sample (#8880)

* Update detecting lost connections sample

Old detecting lost connections using sensors does not work with current HA versions any more.
This commit is contained in:
Markus Haack 2019-03-24 18:35:04 +01:00 committed by Daniel Perna
parent b6f595e3f3
commit ad57ca9f0d

View File

@ -390,20 +390,34 @@ action:
When the connection to your HomeMatic CCU or Homegear is lost, Home Assistant will stop getting updates from devices. This may happen after rebooting the CCU for example. Due to the nature of the communication protocol this cannot be handled automatically, so you must call *homematic.reconnect* in this case. That's why it is usually a good idea to check if your HomeMatic components are still updated properly, in order to detect connection losses. This can be done in several ways through an automation:
- If you have a sensor which you know will be updated frequently (e.g., an outdoor temperature sensor or light sensor) you could set up an automation like this:
- If you have a sensor which you know will be updated frequently (e.g., an outdoor temperature sensor, voltage sensor or light sensor) you could set up a helper binary sensor and an automation like this:
{% raw %}
```yaml
binary_sensor:
- platform: template
sensors:
homematic_up:
friendly_name: "Homematic is sending updates"
entity_id:
- sensor.office_voltage
- sensor.time
value_template: >-
{{as_timestamp(now()) - as_timestamp(states.sensor.office_voltage.last_changed) < 600}}
automation:
- alias: Homematic Reconnect
trigger:
platform: state
entity_id: sensor.outdoor_light_level
for:
hours: 3
entity_id: binary_sensor.homematic_up
to: "off"
action:
# Reconnect, if sensor has not been updated for over 3 hours
service: homematic.reconnect
```
{% endraw %}
The important part is the `sensor.time` entity (from time_date component). This will update the binary sensor on every change of the sensor and every minute. If the Homematic sensor does not send any updates anymore, the `sensor.time` will set the binary sensor to `off` 10 minutes after the last sensor update. This will trigger the automation.
- If you have a CCU you can also create a system variable on the CCU, which stores its last reboot time. Since Home Assistant can still refresh system variables from the CCU (even after a reboot) this is another option to call *homematic.reconnect*. Even though this option might look preferrable to many since it does not rely on a sensor, **it is less fail-safe** than checking for updates of a sensor. Since the variable on the CCU is only changed on boot, any problem that causes the connection between Home Assistant and the CCU to break but will not result in a reboot will not be detected (eg. in case of networking issues). This is how this can be done: