Good day! I’m sorry for the stupid question! How in automation to bind values of sliders to above and below for restriction for example of temperature!
The above:
and below:
numeric trigger options are not template-able. You will have to use a template trigger.
Thanks for the answer! But could you if it is not difficult to write an example! I’m still bad at templates
Sure, here’s a basic example for switching a fan on if a cpu temperature sensor goes above a temperature set by an input number (slider):
- id: rack_fan_on
alias: 'Rack Fan On'
trigger:
- platform: template
value_template: "{{ states('sensor.cpu_temperature')|float >= states('input_number.rack_fan_on_temp')|int }}"
action:
- service: switch.turn_on
entity_id: switch.rack_fan
Thank you very much!
I ask you again, sorry! I did as you suggested to me but here’s the problem when the temperature value is less than or equal to the exposed value (the trigger is turned on), but in the second case when the value is greater than or equal to the value the trigger is not turned off! Or maybe there is a way if else?
- id: rack_Led_on
alias: 'Rack Led On'
trigger:
- platform: template
value_template: "{{ states('sensor.temperature')|int <= states('input_number.target_temp_min')|int }}"
action:
- service: switch.turn_on
entity_id: switch.kitchen_led
- id: rack_Led_off
alias: 'Rack Led Off'
trigger:
- platform: template
value_template: "{{ states('sensor.temperature')|int >= states('input_number.target_tem_max')|int }}"
action:
- service: switch.turn_off
entity_id: switch.kitchen_led
Are you missing a ‘p’ here?
states('input_number.target_tem_max')
^^
And yes, in this case you can do it in one automation with a service template:
- id: rack_Led_control
alias: 'Rack Led Control'
trigger:
- platform: state
entity_id: sensor.temperature
- platform: state
entity_id: input_number.target_temp_max
- platform: state
entity_id: input_number.target_temp_min
action:
- service_template: >
{% if states('sensor.temperature')|int >= states('input_number.target_temp_max')|int %}
switch.turn_off
{% elif states('sensor.temperature')|int < states('input_number.target_temp_min')|int %}
switch.turn_on
{% endif %}
entity_id: switch.kitchen_led
Also if your temperature sensor has fractions of a degree you would be better off with:
- service_template: >
{% if states('sensor.temperature')|float >= states('input_number.target_temp_max')|int %}
switch.turn_off
{% elif states('sensor.temperature')|float < states('input_number.target_temp_min')|int %}
switch.turn_on
{% endif %}
entity_id: switch.kitchen_led
Thank you very much for your help!