What I mainly mean is for devices like switch that shows as outlets, there is no way to easily turn on a smart plug only for 2 hours for example as there is in other platforms. I think that a way to implement this would be when you get to the expanded view of an entity there should be a time selector with the amount of time you want to happen before it toggles.
Yea, I could see that being useful.
There are already several ways to do this, but I agree it could be easier and maybe in this little menu:
This again is an example of asking Home Assistant to automate things for you.
Home Assistant provides a very capable automation editor for you to do this (easily). It does not provide automations.
Or you can let others do it for you by searching the blueprint exchange.
Though having said that, I believe the developers are looking into options for Voice Assist timers “on the fly” that may help. e.g. “hey Nabu, turn my lights on for five minutes”, or “hey Nabu alert me in 10 minutes”,
That voice assist thing would be very useful.
I agree that Home Assistant offers everything you’d need to make anything do anything but I can never get an automation to be this simple:
automation:
- alias: "Turn Plug On for 5 Hours After 17:00"
trigger:
- platform: time
at: "17:00:00" # Time to turn the plug on (5:00 PM)
action:
- service: switch.turn_on
target:
entity_id: switch.your_plug # Replace with your actual plug's entity ID
- delay: "05:00:00" # Wait for 5 hours
- service: switch.turn_off
target:
entity_id: switch.your_plug # Replace with your actual plug's entity ID
Well that is the simplest way. Though waiting in an automation for 5 hours is not good practice. Lots of opportunity for that to be interrupted.
Using two automations would be better. One to turn on the plug at 5pm (time trigger) and one to turn off the plug at 10pm (time trigger).
As another alternative, I often have things that have fixed durations, but non-fixed start times. So if basing the start/stop times off specific times or existing values doesn’t work, you can use an input_datetime
helper in your start script/automation and then perform a time trigger based on the time in that value being reached for your stop. It’s a dynamic solution that can survive reboots.
I understand that, but I see it in a different way.
You could also have an automation that changes the colour/warmness/brightness of a light every time you turn it on, but you also have the option to chose those aspects in the expande view.
I’m sorry I don’t see how changing things manually relates to this at all.
What I want could be solved with a drop down menu with time options for when the entity will toggle, same as we have a drop down menu for color effects in some bulbs.
Why should “turn on lights for 5 minutes” be restriced to voice commands? I have no Voice Assist and am not planning to have it in the near future.
Sometimes I want to do just that and you ask me to write one or even two automations for that?
This could be solved with my WTH here: https://community.home-assistant.io/t/wth-why-cant-i-make-one-off-async-scripts-automations/
For some use cases it might, but not for the majority I would say
Yes exactly that. Home assistant does not write automations for you.
But In some cases you might want X time and in others Y, so I don’t see an automation as an efficient way of doing it
Use an input number for the time. The for:
time in triggers supports this.
trigger: state
entity_id: sensor.foo
to: "bar"
for:
minutes: input_number.foobar_time_in_minutes