Controlling a device with a thermostat card

Hi,

I’ve put together a hot tub and built a controller out of bits and pieces I have had around home so that I can control it remotely and heat it when needed. I saw that a recent update to esphome had the climate options added and wanted to utilise this to control the temperature of the hot tub. Everything has come together alright but I’m missing a few things that I don’t know how to set.

Temperature Control
In Home assistant I’ve added a thermostat card and it controls the ESP8266 ok. The temperature dial has a range of 10-30C and I want to be able to set it to a max of 40C. Is this on the Home Assistant side or ESPhome side? I can’t seem to work out how to change it!

Pump Control
Due to the original hot tub not having a heater (it’s a bath tub with spa pump) I’ve added a heating loop in. There are 2 pumps with one for the jets like you’d expect in a spa, and the other for the water heating loop. I’d like to set the water heating pump on when the heater is turned on, and only turned off when the heater is switch off in HA or when the jet pump is running. When turn the jets on it should also turn off the 2 heating elements. Is this possible?

This is the code I’m using on a nodemcu. The config that isn’t included is just the WiFi config and MQTT config. This device interacts with Home Assistant via MQTT. There are 2 safety limits on the temperature sensors while I work out how to get this bit working correctly.

climate:
  - platform: thermostat
    name: "Hot Tub Controller"
    sensor: hottub_water_temp
    default_target_temperature_low: 37
    heat_action:
      - switch.turn_on: hottub_element_1
      - switch.turn_on: hottub_element_2
      - switch.turn_on: hottub_heater_pump
    idle_action:
      - switch.turn_off: hottub_element_1
      - switch.turn_off: hottub_element_2
      - switch.turn_on:  hottub_heater_pump


switch:
  - platform: gpio
    pin: D7
    id: hottub_element_2
    name: "Hot Tub Element 2"
  - platform: gpio
    pin: D6
    id: hottub_element_1
    name: "Hot Tub Element 1"
  - platform: gpio
    pin: D8
    id: hottub_heater_pump
    name: "Hot Tub Heater Pump"
  - platform: gpio
    pin: D3
    name: "Hot Tub Jet Pump"

dallas:
  - pin: D1

sensor:
  - platform: dallas
    id: hottub_water_temp
    address: 0xD903079779A64B28
    name: "Hot Tub Water Temp"
    on_value_range:
      - above: 38
        then:
         - switch.turn_off: hottub_element_2

  - platform: dallas
    address: 0xF103069779DAC628
    name: "Hot Tub Heater Temp"
    on_value_range:
      - above: 42
        then:
         - switch.turn_off: hottub_element_1
         - switch.turn_off: hottub_element_2

binary_sensor:
  - platform: gpio
    pin:
      number: D5
      mode: INPUT_PULLUP
    name: "Safety Cutout"
  - platform: gpio
    pin:
      number: D2
    name: "Water Flowing"

I think the rest is covered here :slight_smile: https://esphome.io/guides/automations.html#

Hi @nickrout,

Thank you! I can’t believe I didn’t see that when reading through earlier. The max and min temperatures worked a treat so I can now dial between 20 and 40 °C. The bit I don’t get is the automation to make sure one set of items is off when another is switched on. Do you have any examples?