Use input slider as thermostat set point

I started to use HA a month ago and I am trying to create a “home made” RPi thermostat to replace the old one. I can do a fixed set point to trigger cooling start/stop, like this:

trigger:
  platform: numeric_state
  entity_id: sensor.roomtemp
  above: 24

But every time I want to change the set point (say 24C may be too cold, adjust it to 26), I have to modify the configuration file. And I think the input slider could be a good interface for this use case. Will HA allows to use slider value as a variable to be compared with sensor readings? ideally, it will look like this:

trigger:
  platform: numeric_state
  entity_id: sensor.roomtemp
  above: input_slider.cooling_spt.value

Can I do it with the current HA version? Any example around this?

Thanks.

-Ke

1 Like

I am attempting to achieve the exact same thing, but have not yet been successful :-/

Does anyone know if Value Templates (as of 0.19) support evaluating against sliders at all?

Add a third person looking to do this. At the moment I just want to get notified at certain temp settings

alias: Text when temp is above 70 degrees
trigger:
  platform: numeric_state
  entity_id: sensor.weather_temperature
 # Temperature
  above: '{{state.input_slider.temp}}'
condition:
  condition: state
  entity_id: input_boolean.notify_all
  state: 'on'
action:
  - service: notify.notify
    data:
      message: "Temperature is above 70 degrees"

any help or a tip saying this isn’t possible is welcome.

I’m also looking to use input_slider in an automation. but for setting brightness on scenes for lights. But I’m not having much luck finding a working code example. Much like you guys.

As soon as I do though, I will be updating the component page and submitting a PR for it to save others the headache.

Currently it’s not possible to enter a template as value to the above key for the numeric_state platform. A workaround is to use a template sensor as middleman or just use the template trigger in the automation.

Template sensor:

input_slider:
  therm_setpoint:
    name: Thermostat setpoint slider
    initial: 24
    min: -20
    max: 35
    step: 1

sensor:
  - platform: template
    sensors:
      therm_setpoint:
        value_template: >
          {{ (states('sensor.yr_temperature') | float - states.input_slider.therm_setpoint.state | float) | round(0) }}
        friendly_name: 'Thermostat setpoint sensor'
        unit_of_measurement: '°C'
  - platform: yr
    monitored_conditions:
      - temperature

automation:
  - alias: 'Thermostat cool'
    trigger:
      platform: numeric_state
      entity_id: sensor.therm_setpoint
      above: 1
    action:
      service: homeassistant.turn_on
      entity_id: script.telegram
      data:
        variables:
          message: 'Thermostat is cooling!'

Template trigger:

input_slider:
  therm_setpoint:
    name: Thermostat setpoint slider
    initial: 24
    min: -20
    max: 35
    step: 1

sensor:
  - platform: yr
    monitored_conditions:
      - temperature

automation:
  - alias: 'Thermostat cool'
    trigger:
      platform: template
      value_template: >
        {% if (states('sensor.yr_temperature') | float - states.input_slider.therm_setpoint.state | float) | round(0) > 1 %}true{% endif %}
    action:
      service: homeassistant.turn_on
      entity_id: script.telegram
      data:
        variables:
          message: 'Thermostat is cooling!'
1 Like

Hi,
I have a similar scenario and I have tryied to use the code above, but unfortunately it goes in error. I want to start heating when the temperature is between the two input.slider stepoints and humidity is > 49. Here is my code:

input_slider:
temperatura1:
name: SP Tmax
initial: 6
min: 5
max: 10
step: 0.5
temperatura2:
name: SP Tmin
initial: -2
min: -10
max: 0
step: 0.5
umiditate:
name: SP umiditate
initial: 50
min: 0
max: 100
step: 1
automation:

  • alias: “start_degivrare”
    trigger:

    • platform: template
      value_template: >
      {% if ((states(‘sensor.temperatura’) - states.input_slider.temperatura2.state) and (-states(‘sensor.temperatura’) + states.input_slider.temperatura1.state > 0)) %}true{% endif %}
    • platform: numeric_state
      entity_id: sensor.umiditate
      above: 49
      condition:
    • condition: template
      value_template: >
      {% if ((states(‘sensor.temperatura’) | float - states.input_slider.temperatura2.state | float) | round(0) > 0) and ((-states(‘sensor.temperatura’) | float + states.input_slider.temperatura1.state | float) | round(0) > 0) %}true{% endif %}
    • condition: numeric_state
      entity_id: sensor.umiditate
      above: 49

    action:
    service: switch.turn_on
    data:
    entity_id: switch.degivr

What did I do wrong?
thanks.

You should use: https://home-assistant.io/components/climate.generic_thermostat/

the other thing you can do is use the app-daemon.

the whole point of it is to increase automation possibilities, and program in python. there are a bunch of people on here using it as well, and they all seem keen to help everyone else.

I cannot use https://home-assistant.io/components/climate.generic_thermostat/ as I want set the setpoint with input_slider.
I will studyy app-daemon, I hope to manage.
Thanks for help.

Generic thermostat gives you a slider similar to the input slider

I have a similar setup with volume of an AVR. The following cofig works…I am not sure if this helps:

media_player:
platform: denon_avr
host: 192.168.1.101
name: Denon AVR

input_slider:
denon_volume:
name: Volume
initial: 0.3
min: 0
max: 1
step: 0.01

automation 4:

  • alias: Denon - Adjust Volume
    trigger:
    platform: state
    entity_id: input_slider.denon_volume
    action:
    • service: media_player.volume_set
      data_template:
      entity_id: media_player.denon_avr
      volume_level: ‘{{ trigger.to_state.state }}’

Hey all,

I have the following config:

sensor:

  • platform: onewire
    names:
    28-00000xxx: Living

switch:

  • platform: rpi_gpio
    ports:
    17: Releu
    invert_logic: true

automation:
trigger:
platform: numeric_state
entity_id: sensor.living
above: 20
action:
service: homeassitant.turn_on
entity_id: switch.releu

The automation never triggers.
The relay works either manually or if I choose some other trigger.

Any ideas?

Thank you

Daniel can you please confirm that this is the case as I cannot seem to find how to display a slider to set the target temperature or range.

Daniel, I just found that I can adjust the target temperature by clicking on the group item and it is available to me in the pop-up. I had assumed it would display as a group item.

I was hoping to use sliders for this reason as well. I can’t use the generic thermostat because I don’t have the necessary toggle switch (I’ve got a RPi zero hard wired into my central heating controller, so it basically shorts out the ‘advance’ button using a script for the GPIO, which simulates the physical button being pressed).

Has there been any progress with this, or is it still not possible to set the above / below values with the input_slider setting?

I’m building a Raspberry Pi-based thermostat for my heat pump right now. Here’s an overview of the direction I’m taking with it.

The Pi will essentially act as a smart brain for the heat pump. It has the relays to connect with the heat pump controller, and it has the logic for determining when to turn on and off, switch from heat to cool and back, deal with auxiliary and emergency heat, etc. But it will not have sensors; what it will have is communication with HA via MQTT. I’m hacking together some HA controls that will include a master enable switch, slider for set point, manual fan, and emergency heat. Along with the states of those controls, HA will also be sending the outside and inside temps. I’ll also have it send appropriate values when HA goes to and from away mode.

Right now, I’m developing the logic on a Pi 3, but I hope to send it over to a Pi Zero W for final installation at the heat pump. The only UI will be the HA dashboard, so I don’t need a lot of grunt attached to the heat pump.

I’ve just gotten started with HA within the last couple of days, so this is still very alpha, but I’ve made some decent progress so far.

That is actually a very good tip, but I was wondering if there is a way of turning it on/off. If I had it, I could create an automation to also only make it work during certain times of the day.

Any insights are welcome.

I managed to use the imput slider (now known as input_number) to control my heating:

  • alias: “Turn on heat in storage”
    trigger:
    platform: time
    #This will match every 1 minutes
    minutes: ‘/01’
    seconds: 00
    condition:
    condition: template
    value_template: ‘{{states.sensor.storage_temperature.state | float < states.input_number.temp_setpoint_storage.state | float - 2}}’
    action:
    • service: switch.turn_on
      entity_id: switch.heatattefallstorage
1 Like

That seems like an overly aggressive way to handle your heating. Running an automation like that could bog down your system. Why not just trigger off the temperature changes?

alias:  Turn on heat in storage
  trigger:
    - platform: state
      entity_id: sensor.storage_temperature, input_number.temp_setpoint_storage
  condition:
    - condition: template
      value_template: "{{ states.sensor.storage_temperature.state | float < states.input_number.temp_setpoint_storage.state | float - 2 }}"
  action:
    - service: switch.turn_on
      entity_id: switch.heatattefallstorage

You could even manage to use a service_template, remove the condition and turn on / off the switch based on rising and falling.

alias:  Manage heat in storage.
  trigger:
    - platform: state
      entity_id: sensor.storage_temperature, input_number.temp_setpoint_storage
  action:
    - service_template: >
        {% if states.sensor.storage_temperature.state | float < states.input_number.temp_setpoint_storage.state | float - 2 %}
          switch.turn_on
        {% else %}
          switch.turn_off
        {% endif %}
      entity_id: switch.heatattefallstorage
2 Likes

Awesome! That’s a more nice way to treat the temperature changes. I didn’t think about triggering on input_number state change :smile:
Thanks mate!