MartinAM
(Martin Adam Martinsen)
October 29, 2017, 8:38pm
1
Hello.
I have input_number slider that I wan to adjust when the lights turn off (in minutes).
input_number:
bathroom_delay_minutes:
mode: slider
name: Bathroom Light Delay
initial: 5
min: 0
max: 60
step: 1
I alse have a simple automation that turn off light in Bathroon based on motion sensor inactivity.
It turns light off after 5min.
- id: bathroom_light_motion_off
alias: Bathroom Light Motion Off
initial_state: false
trigger:
- platform: state
entity_id: binary_sensor.aeotec_zw100_multisensor_6_001_sensor
to: 'off'
for:
minutes: 5
What I want to do is to use input_number insted og 5 minutes:
Something like this:
minutes: (inoput number slider value here)
I have tried to read documentation up and down, and none of examples works.
I know that there are different ways for this aproach, but I want to know if there is a wa yto put input value intu minutes…
Any one who could hellp?
Martin
matust
October 29, 2017, 8:54pm
2
Try this
- delay: "00:{{ states.input_number.bathroom_delay_minutes.state | int }}:00"
matust
October 29, 2017, 9:01pm
3
Just re read your question, delay won’t as part of the trigger. You could use a script and put the variable delay in there. The action could be script turn off and then script turn on to reset the timer
MartinAM
(Martin Adam Martinsen)
October 29, 2017, 9:42pm
4
I see.
So there is no way to convert input_number so it works with a trigger: minutes:…
Thx…
matust
October 29, 2017, 9:55pm
5
There may well be, hopefully someone with a bit more knowledge will have the answer. I’ve only just started using input_numbers
MartinAM
(Martin Adam Martinsen)
October 31, 2017, 8:46am
6
Then we are in the same boat…
vladosam
(Vladimir)
November 2, 2017, 1:24pm
7
I tried to solve your problem as an exercise.
This will work without script:
- id: bathroom_light_motion_off
alias: Bathroom Light Motion Off
trigger:
- platform: time
seconds: '/10'
condition:
condition: and
conditions:
- condition: template
value_template: "{{(as_timestamp(now())-as_timestamp(states.binary_sensor.aeotec_zw100_multisensor_6_001_sensor.last_updated)) | int > states.input_number.bathroom_delay_minutes.state | int*60 }}"
- condition: state
entity_id: binary_sensor.aeotec_zw100_multisensor_6_001_sensor
state: 'off'
- condition: state
entity_id: BATHROOM_LIGHT
state: 'on'
action:
- service: light.turn_off
entity_id: BATHROOM_LIGHT
MartinAM
(Martin Adam Martinsen)
November 26, 2017, 6:04pm
8
Hello guys.
This thread is outdated due to new version of HA and indroduction of timer.
I manadged to get it to work with timers:
Bathroom Light On By Motion - Begin Code
id: bathroom_light_on_by_motion
alias: Bathroom Light On By Motion
initial_state: true
trigger:
platform: state
entity_id: binary_sensor.aeotec_zw100_node5_multisensor6_sensor
to: ‘on’
action:
service: timer.cancel
entity_id: timer.bathroom_timer
service: switch.turn_on
entity_id: switch.qubino_flush1_node6_inwall_switch
End Code
Bathroom Light Motion Timer On - Begin Code
id: bathroom_light_motion_timer on
alias: Bathroom Light Motion Timer On
initial_state: true
trigger:
platform: state
entity_id: binary_sensor.aeotec_zw100_node5_multisensor6_sensor
to: ‘off’
action:
service: timer.start
entity_id: timer.bathroom_timer
End Code
Bathroom Light Off By Motion - Begin Code
id: bathroom_light_off_by_motion
alias: Bathroom Light Off By Motion
initial_state: true
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.bathroom_timer
condition:
condition: state
entity_id: binary_sensor.aeotec_zw100_node5_multisensor6_sensor
state: ‘off’
action:
service: switch.turn_off
entity_id: switch.qubino_flush1_node6_inwall_switch
End Code
What I am doing is:
When there is a motion: Turn lights on and cancel timer
When there is no motion: start timer
When timer is fininshed: Turn Lights Off.
This works great.
Right now I have timer set to 3 min:
bathroom_timer:
name: Bathroom Timer
duration: ‘00:03:00’
icon: mdi:ceiling-light
But I want to use input_number to control delay.
bathroom_delay_minutes:
mode: slider
name: Bathroom Light Delay
initial: 1
min: 0
max: 10
step: 1
I tried to:
bathroom_timer:
name: Bathroom Timer
duration: “00:{{ states.input_number.bathroom_delay_minutes.state | int }}:00”
icon: mdi:ceiling-light
But I get error.
Any ideas?
You can’t specify a dynamic duration when the timer is initialized. If you do it that way you would have to restart home assistant every time you change the value.
The timer.start
service allows to pass a duration on the fly. So you could use a template for the service data, which then would be evaluated every time the timer is started. The sevice accepts either the time like '00:11:22'
or just raw seconds. It may be easier to just use the value from your input_number and multiply it by 60 instead of trying to convert to the time-format.
1 Like