Need template for trigger netatmo valves

Hi all.
I’ve been trying to improve an automation for two months and I can’t. @Didgeridrew and @123 helped me with the templatehttps://community.home-assistant.io/t/help-with-template-in-automation-to-control-netatmo-valves-with-a-thermostat/363233 and it works but there are many times that it doesn’t and I need help. I put it and explain:

alias: termostato_atico_on_alternativa
trigger:
  - platform: numeric_state
    entity_id: climate.termostato_atiko
    value_template: >-
      {{ ((state_attr('climate.termostato_atiko', 'temperature') | float) -
      (state_attr('climate.termostato_atiko', 'current_temperature') | float)) |
      abs }}
    above: 0.1
condition: []
action:
  - service: script.turn_on
    target:
      entity_id: script.valvula_atico_on
mode: single

alias: termostato_atico_off
trigger:
  - platform: numeric_state
    entity_id: climate.termostato_atiko
    value_template: >-
      {{ (state.attributes.current_temperature - state.attributes.temperature) |
      abs }}
    above: 1
condition: []
action:
  - service: >-
      script.turn_{{ 'on' if state_attr('climate.termostato_atiko',
      'current_temperature')|float >= state_attr('climate.termostato_atiko',
      'temperature')|float else 'off' }}
    target:
      entity_id: script.valvula_atico_off
mode: single

The shutdown automation has no problem, where I have the problem is in the startup. For triogger it, it is MANDATORY that the temperatures are equal and drop 0.1, if the schedule varies the target temperature and it is higher than the temperature, the boiler turns on but the valves are closed.

I have been reading the documentation and the template model has that mandatory feature. In this post of @Didgeridrew Help with template in automation to control netatmo valves with a thermostat - #10 by Didgeridrew . Is there any way to make it work?

Thanks for the help and sorry for the Google translation.

Your turn off automation will fire when your turn off fires as well if the absolute value of the difference is higher than 1. Your problem is in the turn_off automation.

Can you explain, what you want to achieve? It looks like you want to turn on heating, if attribute (target) temperature is below current temperature by 0.1°C and turn it off if current temperatur is above target temperature by 1.0°C?

If so, try:

alias: termostato_atico
description: ''
mode: single
trigger:
  - platform: numeric_state
    entity_id: climate.termostato_atiko
    id: 'on'
    value_template: >-
      {{ (state_attr('climate.termostato_atiko', 'temperature') | float) -
      (state_attr('climate.termostato_atiko', 'current_temperature') | float) }}
    above: 0.1
  - platform: numeric_state
    entity_id: climate.termostato_atiko
    id: 'off'
    value_template: >-
      {{ (state_attr('climate.termostato_atiko', 'current_temperature') | float)
      - (state_attr('climate.termostato_atiko', 'temperature') | float) }}
    above: 1
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: 'on'
        sequence:
          - service: script.turn_on
            target:
              entity_id: script.valvula_atico_on
    default:
      - service: script.turn_off
        target:
          entity_id: script.valvula_atico_on

The shutdown trigger always works fine for me. The one that fails me is the “on”. Hahahaha, for one who thought it was fine… :joy:

Yes, but the shutdown trigger also can occur at the same time as your startup trigger… and that’s why you’re seeing…

Just so you understand, if this template

is above 0.1 with a value of 1.0

This trigger will also fire

I need that as soon as the target temperature is below the ambient temperature, it triggers the automation, regardless of the fact that a moment before they had the same temperature.
for example:
`
target temperature tempewrature
9:55 AM 19º 19.5º

10:00AM 20º 19.5º
`
This does not trigger the automation and the boiler turns on but never heats up because the valves are still closed

I’ll try the code to see what it does, thanks

Ok, now I understand you. I’m going to do tests and tell you if it works, for now I think so. Thanks a lot

wow, it works perfectly with the code you @m0wlheld gave me. I have only corrected the action of the default and it works with a single automation to turn off and turn on.

alias: termostato_atico_controla_valvulas
description: ''
trigger:
  - platform: numeric_state
    entity_id: climate.termostato_atiko
    id: 'on'
    value_template: >-
      {{ (state_attr('climate.termostato_atiko', 'temperature') | float) -
      (state_attr('climate.termostato_atiko', 'current_temperature') | float) }}
    above: 0.1
  - platform: numeric_state
    entity_id: climate.termostato_atiko
    id: 'off'
    value_template: >-
      {{ (state_attr('climate.termostato_atiko', 'current_temperature') | float)
      - (state_attr('climate.termostato_atiko', 'temperature') | float) }}
    above: '1'
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: 'on'
        sequence:
          - service: script.turn_on
            target:
              entity_id: script.valvula_atico_on
    default:
      - service: script.turn_on
        target:
          entity_id: script.valvula_atico_off
mode: single

@petro Thanks for your comments, it’s hard for me to see what I do with the templates. Do you have any documentation to learn how to make templates? What I find and Jinja2 fron Homeassistant I don´t understand.

Home Assistant is wonderful, I have been since October and I am passionate about everything I discover that can be done. And that wonderful community you have. Regards

1 Like