Making a thermostat

I am making a thermostat with Home Assistant to drive a water cooler. I have a relay that kicks on when the temperature is above a threshold and then kicks off when it is below that threshold.

This works fine in testing with me grabbing the temperature sensor with my hand. The relay kicks on after I grab it and turns off after it cools down again.

- id: '1701744722377'
  alias: Water Cooler Thermostat
  description: ''
  trigger:
  - platform: numeric_state
    id: 'On'
    entity_id:
    - sensor.water_temp
    above: 80
  - platform: numeric_state
    id: 'Off'
    entity_id:
    - sensor.water_temp
    for:
      hours: 0
      minutes: 0
      seconds: 1
    below: 75
  condition: []
  action:
  - choose:
    - conditions:
      - condition: trigger
        id:
        - 'On'
      sequence:
      - type: turn_on
        device_id: 140f0cee526a7418ce75c19d309e4a5a
        entity_id: 29c8865a8c66f607907422663befaa57
        domain: switch
    - conditions:
      - condition: trigger
        id:
        - 'Off'
      sequence:
      - type: turn_off
        device_id: 140f0cee526a7418ce75c19d309e4a5a
        entity_id: 29c8865a8c66f607907422663befaa57
        domain: switch
  mode: single

What I can’t figure out is how to incorporate a water sensor. I have a sensor that measures a voltage based on the water level and that is working on it’s own. I multiply that voltage by 1000 to make the settings easier. Basically the thermostat should turn off and remain off if the water level drops below 48V (sensor reading).

I have tried adding conditions in various places, but I’m not figuring this out.

There’s an integration for this:

Oh I didn’t find that, that looks quite useful! Thanks for pointing that out.

That looks to handle a standard HVAC system. I think I have the same question of how to prevent the system from kicking on if there is no water in the reservoir.

This article looks to be on the right track, but it’s using a binary switch and not a water level.

Use the temperature sensor and relay to make your thermostat.

Use an automation triggered by your level sensor to turn the thermostat on and off.

Yeah I’m coming to same conclusion, but trying to figure out how to make a binary sensor based on that voltage level.

I’m close!

You dont need to. Just use numeric state triggers

Ok, I got it working. Appreciate the nudge in the right direction. I am now using a Generic Thermostat, and an automation to turn it off or on if water is present or not.

Here is the automation to look at the water level

- id: '1701751066071'
  alias: Water Cooler Thermostat control
  trigger:
  - platform: state
    entity_id:
    - binary_sensor.water_level
  action:
  - service: "climate.turn_{{ trigger.to_state.state }}"
    target:
      entity_id: climate.water_cooler
  mode: single

Here is the Binary Sensor in configuration.yaml

binary_sensor:
  - platform: template
    sensors:
      water_level:
        friendly_name: "Water Level Sensor"
        value_template: "{{ states('sensor.water_level')  | float > 48 }}"

When I put my sensor in water it kicks on, and when I remove the water it turns off. I think I need a better water sensor but the code works.

Without the binary sensor:

- id: '1701751066071'
  alias: Water Cooler Thermostat control
  trigger:
  - platform: numeric_ state
    entity_id: sensor.water_level
    above: 48
    for: 60 # seconds. If your sensor is noisy
    id: 'on'
  - platform: numeric_ state
    entity_id: sensor.water_level
    below: 48
    for: 60 # seconds. If your sensor is noisy
    id: 'off'
  action:
  - service: "climate.turn_{{ trigger.id }}"  # dont forget to quote your single line templates!
    target:
      entity_id: climate.water_cooler
  mode: single
1 Like

Been running today and going strong, and I’ve been tweaking all the settings to get it the way I want. Loving the Generic Thermostat UI and config.

1 Like