Help with input_number for light timer automation

the action will be activated on any of 2 separate triggers (i.e when the slider was moved OR state of the humidity sensor has changed) AND the condition evaluates to True, i.e humidity > slider_value.

1 Like

Blockquote[quote=ā€œAhmadK, post:21, topic:126604ā€]
the action will be activated on any of 2 separate triggers (i.e when the slider was moved OR state of the humidity sensor has changed) AND the condition evaluates to True, i.e humidity > slider_value.
[/quote]

Just arrived home so can test it.

But from what you are saying the following code will work for me

trigger:
  - platform: state
    entitiy_id: sensor.test_humidity

condition:
  - platform: template
    value_template: "{{ states('sensor.test_humidity') | float > states('input_number.ensuitefanhum') | float }}"
action:
  - service: fan.turn_on
    entity_id: fan.ensuite_fan

Just removed the slider from the trigger as I only want it to trigger on the humidity state change.

if you remove the slider from triggers and decide to change the value, guess what happens?

I am assuming it will constanly trigger, but the condition will stop it.

Kind of a bit like my work around method where I have it triggering every 15 seconds but the condtion stops it.

Test it. And read docs, seriously.

WIll do and I have been.

Appears I miss read the orginal statement.

Removing the slider from the trigger and chaning the slider value will still work but only once the humidity state changes which will trigger the automation again with the new value.

Exactly. So remove the slider if youā€™re happy with it and donā€™t want to guess what difference it makes :wink:

doing this now.

The time_pattern method was just a dirty way and I clearly did not see the most practical method even tho it was staring me directly in the face. I knew it was there but tried to over complicate it

I have problem regarding automation with time use ā€œforā€ with slider optionā€¦

image

Automation (not working):

# Prižgi SCHRACK ventilacijo - KABINET: Če je temperaturni senzor več kot 25 stopinj
- id: '3001'
  alias: SCHRACK - prižgi VENTILATOR
  trigger:
#    platform: numeric_state
#    entity_id: sensor.schrack_t
#    above: '25'
    platform: template
    value_template: "{{ is_state('binary_sensor.schrack_prizgi_ventilator_boolean', 'on') }}"
    for:
#      hours: 0
      minutes: "{{ states('input_number.variable_kabinet_prizgi_schrack_ventilator_minuta') | int }}"
#      seconds: 0
    platform: state
    to: 'on'
  condition:
      - condition: state
        entity_id: switch.schrack_fan
        state: 'off'
      - condition: state
        entity_id: binary_sensor.schrack_ugasni_ventilator_boolean
        state: 'off'
  action:
    service: switch.turn_on
    entity_id: switch.schrack_fan  # Use the actual name of your switch here

Input_number:

# SCHRACK - časovni prag - prižgi
    variable_kabinet_prizgi_schrack_ventilator_minuta:
      name: Časovni prag
      min: 0
      max: 60
      step: 1
      icon: mdi:timer-sand
      unit_of_measurement: "min"

So what Iā€™m doing wrong?

I also tried withouth
platform: state
to: ā€˜onā€™
but the result is the same (configuration test OK), but automation is not working. If I write instead of input_number static number, like 15 (for: minutes: 15), then itā€™s working fine.

You definitely need to remove that. Assuming you did, and restarted, it should work. Are you sure input_number.variable_kabinet_prizgi_schrack_ventilator_minuta has a valid (numeric) value?

EDIT: The configuration checker seems to be complaining about the value_template at line 196. Assuming thatā€™s what you showed in your post, I donā€™t see anything wrong with it. Are you sure itā€™s not complaining about a different automation?

So, the input_number.variable_kabinet_prizgi_schrack_ventilator_minuta probably has correct valueā€¦
Itā€™s defined as:

# SCHRACK - časovni prag - prižgi
    variable_kabinet_prizgi_schrack_ventilator_minuta:
      name: Časovni prag
      min: 0
      max: 60
      step: 1
      icon: mdi:timer-sand
      unit_of_measurement: "min"

image

Also, if I comment the ā€œminutesā€ sensor under for function everything is working fine.
Also, the configuration error is out if I comment platform to on stateā€¦

# Prižgi SCHRACK ventilacijo - KABINET: Če je temperaturni senzor več kot 25 stopinj
- id: '3001'
  alias: SCHRACK - prižgi VENTILATOR
  trigger:
#    platform: numeric_state
#    entity_id: sensor.schrack_t
#    above: '25'
    platform: template
    value_template: "{{ is_state('binary_sensor.schrack_prizgi_ventilator_boolean', 'on') }}"
    for:
      hours: 0
      minutes: 15 #"{{ states('input_number.variable_kabinet_prizgi_schrack_ventilator_minuta') | int }}"
      seconds: 0
#    platform: state
#    to: 'on'
  condition:
      - condition: state
        entity_id: switch.schrack_fan
        state: 'off'
      - condition: state
        entity_id: binary_sensor.schrack_ugasni_ventilator_boolean
        state: 'off'
  action:
    service: switch.turn_on
    entity_id: switch.schrack_fan  # Use the actual name of your switch here

image

But if I use automation as this:

# Prižgi SCHRACK ventilacijo - KABINET: Če je temperaturni senzor več kot 25 stopinj
- id: '3001'
  alias: SCHRACK - prižgi VENTILATOR
  trigger:
#    platform: numeric_state
#    entity_id: sensor.schrack_t
#    above: '25'
    platform: template
    value_template: "{{ is_state('binary_sensor.schrack_prizgi_ventilator_boolean', 'on') }}"
    for:
      hours: 0
      minutes: "{{ states('input_number.variable_kabinet_prizgi_schrack_ventilator_minuta') | int }}"
      seconds: 0
#    platform: state
#    to: 'on'
  condition:
      - condition: state
        entity_id: switch.schrack_fan
        state: 'off'
      - condition: state
        entity_id: binary_sensor.schrack_ugasni_ventilator_boolean
        state: 'off'
  action:
    service: switch.turn_on
    entity_id: switch.schrack_fan  # Use the actual name of your switch here

then automation do not work (but withouth any configuration error) - trigger is not workingā€¦

So probably the problem is in minutes formating, but donā€™t know where I make mistake?

What version of HA are you using?

image

Is binary_sensor.schrack_prizgi_ventilator_boolean changing from 'off' to 'on', and then staying 'on' for the full 15 minutes?

Although what you have looks ok, and you can use a template trigger, I wonder why you donā€™t use a state trigger instead. E.g.:

  trigger:
    platform: state
    entity_id: binary_sensor.schrack_prizgi_ventilator_boolean
    to: 'on'
    for:
      minutes: "{{ states('input_number.variable_kabinet_prizgi_schrack_ventilator_minuta') | int }}"
1 Like

Yes, binary_sensor is ON for 15 minutes - because automation is working with static 15 minutesā€¦

Iā€™m testing now with your code if there will be some differencesā€¦ I will report in 20 minutesā€¦

What do you get if you put this in the Template Editor:

{{ states('input_number.variable_kabinet_prizgi_schrack_ventilator_minuta') | int }}

Probably correct:

Currently set time to 4 minutesā€¦

Ok, thanks. Well, I canā€™t explain why things werenā€™t working for you in the first place. Thereā€™s got to be some detail that is missing.

and WOWā€¦

image

Now itā€™s working with your codeā€¦ GREAT JOB!

Thank you many timesā€¦

1 Like

Again, what you had originally (well, without the conflicting platform entries) should have worked, too. But as long as itā€™s working nowā€¦ :smiley: