Generic thermostat with ESP8266

Hello!

I’ve been trying with home assistant for a time, on a Rpi 3 with hassio.

I’m testing Generic Thermostat (climate) component for myself.
It works fine. The base hardware is a Wemos D1 mini with Espeasy 2.0 firmware, sensor is SHT30 and there is a relay atached to its GPIO. The communication between HA and the esp8266 module is MQTT (I use mosquito).
All the things works stable (except when I try new things :slight_smile: )

In the next phase I would like to attach an oled display to the esp to show the target temperature and the sensors temp and humidity readings. I think it will be easy when the display arrives from china :slight_smile:

And here comes my question:
I would like to add two phisical buttons to esp8266 to increase and decrease the target temperature.
I already have these buttons, and I can see the changes in HA.
But how can I incude the increase/decrease in HA?
In climate services there is the climate.set_temperature but it can be used only with exact temperatuse.
I just don’t know what to write to the script to increase/decrease.
Now this is a srcipt I’m trying:

> halotplus:
>   alias: "Háló termosztát +1"
>   sequence:
>     - service: climate.set_temperature
>       data:
>         entity_id: climate.halo
>         temperature: 20

What shoud I write to temperature to incresae the actual target temperature with 1 or 0,5 °C ?

Thanks in advance.

You could probably use a template to fetch the current target temperature, and then add one.

Yes, I tought that this is the solution.
The problem is that I’m too dumb to do this.
I’ve read the templating page on home assistan page, but it’s not for beginners :slight_smile:

So I just wrote this:

- alias: "Háló termosztát +1°C"
  trigger:
    platform: state
    entity_id: binary_sensor.esp_up
    from: 'off'
    to: 'on'
  action:
    service: climate.set_temperature
    data_template:
      entity_id: climate.halo
      temperature: {{ states.climate.halo.attributes.temperature | float + 1 }}

And i get this in the log:

2017-12-29 12:21:07 ERROR (SyncWorker_3) [homeassistant.util.yaml] invalid key: "OrderedDict([('states.climate.halo.attributes.temperature | float + 1', None)])"
  in "/config/automations.yaml", line 77, column 0
2017-12-29 12:21:07 ERROR (MainThread) [homeassistant.components.automation] invalid key: "OrderedDict([('states.climate.halo.attributes.temperature | float + 1', None)])"
  in "/config/automations.yaml", line 77, column 0

Any hints?

You’re certainly on the right lines. There is a similar action at the bottom of this documentation page:

Have you tried putting {{ states.climate.halo.attributes.temperature | float + 1 }} into the Template page in HA to ensure a valid value is returned?

Also, it may be worth trying int instead of float as the component appears to be expecting whole numbers. I don’t think this will fix the issue raised, but it may well prevent another one.

Also try single quotes around {{ states.climate.halo.attributes.temperature | int + 1 }}

Yes, I’m clutching at straws!

Hey!

The aphostrophes worked :slight_smile:
Thank you!

hey can you share your project please

Hello!

I stopped working on this, cos I’m waiting some components to arrive.

But here are my steps:

  1. So as you read flash the d1 mini with espeasy mega (2.0)
  2. Set up mosquito on HASS
  3. Set up the d1 mini to communicate via mqtt (watch out for these little bastards -> / , they are important in mqtt addresses)
  4. Set up temperature sensor and the buttons

Now you have to set up a climate component
https://home-assistant.io/components/climate.generic_thermostat/
Just follow the article its the easy part.

If you have done everything right you have a thermostat where you read the temperature from a sensor wired to the d1 mini, and you can control an output on the mini with it.

If you want to use hardwired buttons at the d1 mini to increase/decrease the temperature you can use sime lines like these:

automations
- alias: "Target temp +1"
  trigger:
    platform: state
    entity_id: binary_sensor.esp_up     <-    this is the increase buttons mqtt sensor entity name so change it to yours
    from: 'off'
    to: 'on'
  action:
    service: climate.set_temperature
    data_template:
      entity_id: climate.halo
      temperature: '{{ states.climate.halo.attributes.temperature | float + 1 }}'
- alias: "Háló termosztát -1°C"
  trigger:
    platform: state
    entity_id: binary_sensor.esp_down          <-    this is the decrease buttons mqtt sensor entity name so change it to yours
    from: 'off'
    to: 'on'
  action:
    service: climate.set_temperature
    data_template:
      entity_id: climate.halo
      temperature: '{{ states.climate.halo.attributes.temperature | float - 1 }}'

Where you read climate.halo there you have to write your thermostat entity name.

After this if you push increase/decrease button, the terget temperature will change.

I found one tiny problem with this setup. If you pressing buttuns too fast when the HASS sends the d1 mini command to “turn ON” the output, the d1 mini can freeze. But after a warm boot it will be in the wanted state. It can be avoided if you press the buttons slow.

Why do you have buttons as binary_sensors?

Since they are push buttons it seemed logical for me.