So far, I’ve been using automation to control smart plugs but now have a use case to turn on an unswitched power outlet for a predetermined number of minutes using the HA app.
I’ve read through a lot of documentation and can do this by configuring and running an automation but not a way to create a switch icon on a dashboard for my wife that she can click on. Surely there must be one.
As other folks said, you can use automations to link a switch or input_boolean to the operation of the power outlet. The switch/input_boolean is what you’d show in your dashboard.
In addition, once you link the switch/input_boolean, you could use a variation of these are two automations I use along with a switch that turns on and off my outside tap (used for watering our gardens).
- alias: 'timing-Outside Tap off after 2 hours'
trigger:
platform: state
entity_id: switch.outside_tap
to: 'on'
for: '02:00:00'
condition:
condition: state
entity_id: switch.outside_water_valve_lock
state: 'off'
action:
- service: switch.turn_off
entity_id: switch.outside_tap
- alias: 'timing-Outside Tap lock off when Tap shut off'
trigger:
platform: state
entity_id: switch.outside_tap
to: 'off'
action:
- service: switch.turn_off
entity_id: switch.outside_water_valve_lock
- alias: 'timing-Outside Tap on when Tap lock turned on'
trigger:
platform: state
entity_id: switch.outside_water_valve_lock
to: 'on'
action:
- service: switch.turn_on
entity_id: switch.outside_tap
So I created the Helper called recirculator_one_shot but this automation doesn’t seem to be triggered when I turn it on in a dashboard card. Can someone spot the bug?
The automation runs properly when clicking on Run Action so it seems to be the trigger
You need to change the states. most states are always lower case but you can check the actual states in the dev tools → states page. Case is important.
trigger:
- platform: state
entity_id: input_boolean.recirculator_one_shot
from: 'off'
to: 'on'
for:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0