albert-canfield / HA-panel-esphome

12 stars 2 forks source link

Automation/Scripts in Ha for sync setpoint temperature #7

Closed kroon040 closed 2 months ago

kroon040 commented 2 months ago

Hi,

I was also created the set temperature for my thermotat. with the input number I also tried to sync the temp between the Homeassistant and the panel. When changing one step, it works. Only doing a couple steps at once, it continues in a loop, bot automation triggers each. Do you also have this problem? Or a better solution?

these are my automations/scripts.

automations

alias: zoldersetpoint
description: ""
trigger:
  - platform: state
    entity_id:
      - input_number.house_temperature_setpoint
condition: []
action:
  - action: script.zoldersetpoint_climate
    metadata: {}
    data: {}
mode: single
alias: Zoldersetpoint2
description: ""
trigger:
  - platform: state
    entity_id:
      - climate.radiator_zolder
    attribute: temperature
condition: []
action:
  - action: script.zoldersetpoint
    metadata: {}
    data: {}
mode: single

and the 2 scripts


alias: zoldersetpoint
sequence:
  - data:
      value: "{{ state_attr('climate.radiator_zolder', 'temperature') }}"
    target:
      entity_id: input_number.house_temperature_setpoint
    action: input_number.set_value
mode: single
description: ""
alias: zoldersetpoint_climate
sequence:
  - data:
      temperature: "{{ states('input_number.house_temperature_setpoint') }}"
    target:
      entity_id: climate.radiator_zolder
    action: climate.set_temperature
mode: single
description: ""
kroon040 commented 2 months ago

found a solution with a condition, and only 2 automations


alias: Sync Climate Temperature from Slider
description: Update the climate device temperature when the slider is changed
trigger:
  - platform: state
    entity_id: input_number.house_temperature_setpoint
condition:
  - condition: template
    value_template: "{{ state_attr('climate.radiator_zolder', 'temperature') | float != states('input_number.house_temperature_setpoint') | float }}"
action:
  - service: climate.set_temperature
    target:
      entity_id: climate.radiator_zolder
    data:
      temperature: "{{ states('input_number.house_temperature_setpoint') | float }}"
mode: single
alias: Sync Slider from Climate Temperature
description: Update the slider when the climate device temperature is changed
trigger:
  - platform: state
    entity_id: climate.radiator_zolder
    attribute: temperature
condition:
  - condition: template
    value_template: "{{ state_attr('climate.radiator_zolder', 'temperature') | float != states('input_number.house_temperature_setpoint') | float }}"
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.house_temperature_setpoint
    data:
      value: "{{ state_attr('climate.radiator_zolder', 'temperature') | float }}"
mode: single