Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Automation: thermostat without error loop?

$
0
0

@prankousky wrote:

Hi everybody,

my current automation for changing thermostats depending on corresponding window state is pasted at the bottom. I use Xiaomi Aqara sensors for my windows and Eurotronic SPZB0001 thermostats for my climate entities.

Unfortunately, those thermostats sometimes randomly disconnect from zigbee2mqtt; when this happens, the current automation will create an infinite error loop, resulting in the entire zigbee2mqtt network eventually going down!! It will constantly send the same command to that (in this case not responding thermostat), which will first slow down all traffic via z2m, then eventually even kill all activities (so I cannot control anything, nor read values, via zigbee2mqtt).

I am trying to create an automation that will

  • be triggered when either a window status, or a climate entity status changes
  • when window got set to open, turn thermostat to “off” if not already off; when window got set to close, turn thermostat to “auto” if not already auto; do this only once, and if there is no response from the climate entity, do x (send message similar to below)
  • when thermostat got set to anything but “off”, check whether window is shut. if yes, do nothing; if no, turn thermostat “off”; if window status cannot be read (for example, if there has been a restart and the state from before the restart had not been saved), do x (for example, send notification “thermostat changed, but window does currently not have a valid status”.

My current test looks like this

{% set my_window = "on" %}
{% set my_heater = "off" %}
{% if (my_window == "on") %}
 {% if (my_heater == "on") %}
   hvac_mode: "off"
 {% else %}
   hvac_mode: "auto"
 {% endif %}
{% else %}
  aus
{% endif %}

This should work, but would be rather confusing when it’s done, as I would need a bunch of nested if statements. Also, I am not sure if I can even figure out the entire structure I’d need to build based on my needs stated above.

The automation I had previously been using is below. It does work, but as soon as an entity does not change accordingly (as mentioned above, those SPZB0001 thermostats often disconnect and/or will not work correctly - even if still connected). I had intense problems with zigbee2mqtt until I deactivated this automation, because it caused the an infinite error loop.

Just to clarify: the automation is fine in theory. It will work. The reason I cannot use it is that those unreliable thermostats make it function other than intended. If the thermostats worked reliably, the automation could be as stated above without any trouble.

automation:
  - alias: "[Heizungen] Auto On/Off"
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.arbeitszimmer_fenster_contact
          - binary_sensor.kueche_fenster_contact
          - binary_sensor.jonna_fenster_contact
    action:
      - service: climate.set_hvac_mode
        data_template:
          entity_id: >
            {% set zimmer = trigger.to_state.object_id.split('_')[0] %}
            climate.{{zimmer}}_heizung_climate
          hvac_mode: >
            {% if trigger.to_state.state == "on" %}
            off
            {%elif trigger.to_state.state == "off" %}
            auto
            {% endif %}

  - alias: "[Heizungen Fenstercheck]"
    trigger:
      - platform: state
        entity_id: 
          - climate.arbeitszimmer_heizung_climate
          - climate.jonna_heizung_climate
          - climate.kueche_heizung_climate
    action:
      - service: climate.set_hvac_mode
        data_template:
          entity_id: >
            {% set raum = trigger.to_state.object_id.split('_')[0] %}
            climate.{{raum}}_heizung_climate
          hvac_mode: >
            {% set fenster = 'binary_sensor.' ~ trigger.to_state.object_id.split('_')[0] ~ '_fenster_contact' %}
            {% if states(fenster) == "on" %}
            off
            {% elif states(fenster) == "off" %}
            auto
            {% endif %}

Thank you for your ideas :slight_smile:

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>