I have a electrical heater on the attic, which I’ve integrated in Lovelace. I’m not using the attic often, primarily to hang up my laundry. So I would like this heater on 2 ways in Lovelace:
a button which switches the heater to on/of, when I would like to be for a longer time on the attic.
a button which trigers a timer for a few (2 or 3) hours, so I can use the heater to speed up the laundry drying process a bit.
So in short, I’ve 1 “heater switch entity” and I would like to give it “on/off” & “timer” functions under 2 sepperate buttons. Is this possible?
I assume I have to copy this “heater switch entity” somehow?
I’ve had tried to do the following in the meanwhile, whit no luck.
I’ve copied the entity of the heater in configuration.yaml to:
# BW-SHP2_02
So now having 2 heater entities, “Heater” & “Heater (timed)”, which are both fuctioning in Lovelace when I click them.
Then I tried to follow these instructions, maybe I’m doing something wrong here, but it the heater is not switching of after 30 sec. when clicked the Heater (timed) entity button.
# Example configuration.yaml entry
timer:
test:
duration: '00:00:30'
and:
# Example automations.yaml entry
- alias: Timerswitch
id: 'Timerstart'
# Timer is started when the switch pumprun is set to on.
trigger:
- platform: state
entity_id: switch.heater_(timed)
to: 'on'
action:
- service: timer.start
entity_id: timer.test
I was thinking missing something in this yes, thanks!
Edit:
Think I don’t understand it verry well yet. But this however seems to work:
- alias: Timerswitch
id: 'Timerstart'
# Timer is started when switch.heater is set to on.
trigger:
- platform: state
entity_id: switch.heater
to: 'on'
action:
- service: timer.start
entity_id: timer.test
- alias: Timerstop
id: 'Timerstop'
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.test
action:
- service: switch.turn_off
entity_id: switch.heater
But now this timer is triggered every time I click this heater entity. How can I create a separate option for toggle (under a separate button ofcourse)?
I could solve this by directing the “entity_id:” to a specific card or name (for example laundry) instead of directing it to “switch.heater” I guess? Don’t know if this will be possible/accepted?
trigger:
- platform: state
entity_id: switch.heater
to: 'on'
The way I would do this is to have only the original heater configuration (no duplicate component).
Turn it on and off manually via the heater front end switch.
Or by switching an input boolean to get a timed heating period. The timed heating or manually operated heating can be manually cancelled by switching off either the heater switch or timer switch.
Have a timed automation to turn it off after the time expires.
automation:
- id: timed_heat_on
alias: 'Timed Heat On'
trigger:
entity_id: input_boolean.timed_heat
platform: state
to: 'on'
action:
service: switch.turn_on
switch.heater
- id: timed_heat_off
alias: 'Timed Heat Off'
trigger:
entity_id: switch.heater
platform: state
to: 'on'
for:
hours: 3
condition: ### only turn off if timed heating activated
condition: state
entitiy_id: input_boolean.timed_heat
state: 'on'
action:
- service: switch.turn_off
switch.heater
- service: homeassistant.turn_off
input_boolean.timed_heat
- id: manual_heat_off
alias: 'Manual Heat Off' ### turn off by any switch
trigger:
platform: state
- entity_id: switch.heater
- entitiy_id: input_boolean.timed_heat
to: 'off'
action:
- service: switch.turn_off
switch.heater
- service: homeassistant.turn_off
input_boolean.timed_heat
There’s quite a bit of redundant action in that last automation but it does not hurt to turn off a switch that is already off and it catches all situations this way.
Create an entities card with your heater switch and the input boolean in it. Set the actual on time to a minute or two instead of 3 hours, reload the automations and test the scenarios.