Unable to modify thermostat temperature setpoint

Hello,

I am trying to build a thermostat that is controlled both by HA interface and physical buttons. I have a DHT11 (will be replaced by 22), a OLED display (temperature, humidity, setpoint) and 2 buttons (+ and - for setpoint) connected to NodeMCU. I am using this configuration because not everyone visiting the house will be technical enough to use HA.
I have created a generic thermostat that receives information from sensor via mqtt. Everything works well. I have also managed to make the buttons modify the temperature setpoint of the thermostat, BUT only to another value.

The following code works:

  • id: ‘123456’
    alias: Automation Thermostat 2
    trigger:
    • entity_id: binary_sensor.switch2
      from: ‘off’
      platform: state
      to: ‘on’
      condition: []
      action:
    • data:
      temperature: 21
      service: climate.set_temperature

But if I change 21 to
{{ states.climate.thermostat2.attributes.temperature | float + 1 }}
it does nothing.

I tried calling the service separately, it says “Failed to call service”. Tested the syntax in templates and it works. What am I doing wrong?

Two things. First, always format YAML code properly using the instructions at the top of the page so we can read it. :slight_smile:

Second, use data_template: instead of data:.

Thank you for the quick answer. I tried, nothing happened.

- id: '123456'
  alias: Automation Thermostat 2
  trigger:
  - entity_id: binary_sensor.switch2
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data_template:
      temperature: {{ states.climate.thermostat2.attributes.temperature | float + 1 }}
    service: climate.set_temperature

This is the code I have now. Also, after modifying in automations.yaml, Configuration ->Automation->Automation Thermostat 2 returns a white screen.

You need to quote your template:

  action:
  - data_template:
      temperature: "{{ states.climate.thermostat2.attributes.temperature | float + 1 }}"
    service: climate.set_temperature
1 Like

Thank you pnbruckner,
I figured it out seconds ago :slight_smile:

Hi Cristian
Please help me, what settings did you use to read setpoint temperature from home assistant on oled. In the forum I found just how to enter the date and temperature of the DHT22 sensor but nothing about setpoint.

Salut Adrian,

Pe OLED afisez temperatura si setpoint. Temperatura o afisez direct, fara sa mai treaca prin HA. Cat despre setpoint, folosesc input number in configuration.yaml pentru a seta temperatura dorita, ca mai jos:

input_number:
  target_bedroom1:
    name: 'Bedroom 1 Slider'
    min: 15
    max: 30
    step: 1
    unit_of_measurement: "°C"
    icon: mdi:target

Apoi am facut un script in scripts.yaml care sa publice pe MQTT valoarea lui input number:

#Setpoint bedroom1
setpoint1:
  sequence:
    service: mqtt.publish
    data_template:
      topic: "setpoint1/setpoint1"
      payload:  '{{ states.input_number.target_bedroom1.state | int }}'

Si in final am facut o automatizare in automations.yaml care sa ruleze scriptul ori de cate ori se schimba input number:

#Setpoint Bedroom1
- id: '111114'
  alias: Automation Setpoint Bedroom1
  initial_state: true
  trigger:
  - entity_id: input_number.target_bedroom1
    platform: state
  action:
   service: script.setpoint1

Partea de cod din NodeMCU nu am cum sa ti-o dau ca e pe alt coputer la care nu am acces momentan. Insa pot sa iti fac un rezumat scurt: citesti valoarea de pe mqtt si o pui pe OLED (poti folosi exemple de la light dimming, e acelasi principiu). Nu uita sa dai subscribe in NodeMCU la topicul MQTT pe care trimiti setpointul (setpoint1/setpoint1 in cazul de fata). Daca nu te descurci, cand mai ajung la computerul cu codul din NodeMCU, ti-l dau si pe ala.

Zi usoara!

1 Like

Mulțumesc frumos pentru răspuns dar am primit între timp un exemplu de setări in grupul Home Assistant de pe Facebook și așa arată montajul meu final.


Ar mai fi o setare pe care nu reușesc să o fac. Proiectul meu are două piese:

  • prima este termostatul care are și releul pentru deschiderea electrovalvei caloriferului pe care se montează.
  • a doua este releul care comanda pornirea încălzirii apei centralei.
    Cele două le-am setat să se deschidă și închidă după cum este temperatura comandata de termostat. Dar dacă din diferite motive accidental se oprește alimentarea montajului de la centrala, la restart nu mai citește statusul termostatului decât când primește impuls de la el.