bachoo786
(Bachoo786)
November 14, 2017, 11:24pm
1
Hi
So I am trying to select an input from my frontend to trigger an action in this case I am trying to turn on my heater for ‘X’ number of minutes. Here is my code but it doesnt work as intended:
automation:
- alias: 'Turn heater on for 5 minutes'
initial_state: True
trigger:
- platform: homeassistant
event: start
action:
- service: switch.turn_on
entity_id: switch.heater
- delay: '00:05:00'
- service: switch.turn_off
entity_id: switch.heater
Input Select:
input_select:
heater:
name: 'Turn on Heater'
options:
- 'automation.turn_heater_on_for_5_minutes'
Can anyone please help?
Thanks.
keithh666
(Keith Hull)
November 15, 2017, 1:41am
2
You are triggering from HA startup…
It should look like this…
- alias: Turn heater on for 5 minutes
# hide_entity: false
initial_state: 'on'
trigger:
- platform: state
entity_id: input_select.heater_bedroom
to: "Turn_On_Heater"
action:
- service: switch.turn_on
entity_id: switch.heater
- delay: '00:05:00'
- service: switch.turn_off
entity_id: switch.heater
and your input_select should look like this…
heater_bedroom:
name: Bedroom Heater Options
options:
- Turn_On_Heater
- Turn_Off_Heater
- None
initial: None
Notice I didn’t call my input_select the same name as my switch
bachoo786
(Bachoo786)
November 15, 2017, 6:36pm
3
Thanks Keith.
All works well. I had a question with regards to the input selection; If I select “Turn_On_Heater” the heater turns on for 5 mins, however if I then select “None” I expect nothing to happen which is fine but if I select “Turn_On_Heater” again it turns the heater off. I would have expected it not to do anything?
Also in the options can I get away with the underscore and use spaces?
And finally in the automation for “None” what shall I put as an action?
Thanks mate.
keithh666
(Keith Hull)
November 15, 2017, 7:01pm
4
I don’t know why it would turn off the heater, it shouldn’t unless the delay is getting by passed somehow.
In the options you can indeed use spaces…
lullaby:
name: Lullaby
options:
- Heavy Rain MP3
- Rain In The Woods 10hrs MP3
- Rain and Thunder MP3
- Babbling Brook MP3
- Ocean Waves MP3
- Watersounds Bird Song MP3
- FireplaceBurning AVI
- Campfire by the River AVI
- WaterfallOceanBeach AVI
- Coral Reef Aquarium AVI
- None
initial: None
icon: mdi:weather-rainy
I wouldn’t bother with an automation for none it’s just there if you don’t want to select off or on.
1 Like
bachoo786
(Bachoo786)
November 15, 2017, 7:18pm
5
Thanks buddy.
@Tinkerer could you please share your thoughts as to why the delay is getting by passed when I select the “Turn_on_heater” after selecting delay.
Thanks.
Tinkerer
(aka DubhAd on GitHub)
November 15, 2017, 8:59pm
6
Does the Logbook show anything?
It’s possible the issue is just that the delay is too long. I’d suggest splitting it into 2:
- alias: Turn heater on for 5 minutes
initial_state: 'on'
trigger:
- platform: state
entity_id: input_select.heater_bedroom
to: "Turn_On_Heater"
action:
- service: switch.turn_on
entity_id: switch.heater
- service: input_boolean.turn_on
entity_id: input_boolean.heater_bedroom
- alias: Turn heater off after 5 minutes
initial_state: 'on'
trigger:
- platform: state
entity_id: switch.heater
to: 'on'
for:
minutes: 5
condition:
- condition: state
entity_id: input_boolean.heater_bedroom
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.heater
- service: input_boolean.turn_off
entity_id: input_boolean.heater_bedroom
Obviously you also need the matching input_boolean:
input_boolean:
heater_bedroom:
name: Bedroom heater turned on by an automation
initial: off
1 Like
bachoo786
(Bachoo786)
November 15, 2017, 9:46pm
7
Logbook doesnt show anything just for the heater on and heater off i.e. as soon as I select “None” and then select “Turn_On_Heater” again it turns the heater off.
keithh666
(Keith Hull)
November 15, 2017, 11:24pm
8
What does it do if you don’t select none?
keithh666
(Keith Hull)
November 15, 2017, 11:32pm
10
So remove none from the input_select and set the initial to off or on and you are good to go
bachoo786
(Bachoo786)
November 18, 2017, 1:34pm
11
@Tinkerer your automation solved it thanks !
If I wanted to turn the heater on for 3 minutes, its the same code just the minutes to 3 correct?
bachoo786
(Bachoo786)
November 18, 2017, 3:23pm
13
Thanks !
Can the title of the card “Input Select” be changed?
i.e.
elRadix
(elRadix)
November 18, 2017, 4:34pm
14
can you share the full config code, I also want to use flexible timed heating if that’s possible, ie 1 hour upto 5 hours
Tinkerer
(aka DubhAd on GitHub)
November 18, 2017, 5:19pm
15
Just give the group a name:
bachoo786
(Bachoo786)
November 18, 2017, 8:36pm
16
well its not in a group its just like this:
input_select:
heater_bedroom:
name: Bedroom Heater
options:
- 'Heater on for 5 mins'
- 'None'
initial: 'None'
icon: 'mdi:fan'
bachoo786
(Bachoo786)
November 18, 2017, 8:45pm
17
ok made a group and sorted it. Thanks for your help.
bachoo786
(Bachoo786)
November 18, 2017, 8:51pm
18
@elRadix The code I used is the one provided by @Tinkerer :
Tinkerer:
Does the Logbook show anything?
It’s possible the issue is just that the delay is too long. I’d suggest splitting it into 2:
Obviously you also need the matching input_boolean:
input_boolean:
heater_bedroom:
name: Bedroom heater turned on by an automation
initial: off
In the minutes where it says 5 i.e
trigger:
- platform: state
entity_id: switch.heater
to: 'on'
for:
minutes: 5
change it to 60 (1 hour) or 300 (5 hours) whichever you prefer.
or use hours instead of minutes i.e.
for:
hours: 5
Hi thank you for the code it works great for my pool.
Was just wondering can the state change back to none when the 5 min/hours is over?