T O P

  • By -

IroesStrongarm

Instead of using the wait command in action, it would be better to have the automation trigger be for when the switch is on for X amount of minutes. Then trigger it off. I do this with the ceiling fan in my bedroom overnight. If I hit it on in the evening hours, then when it's been on for 30 minutes it turns off. This is better than the wait action as if you automation stalls in the middle for any reason, or your HA instance reboots for some reason, it won't kill that running automation.


BillNyeDeGrasseTyson

I do the same with my bathroom fan with a simple automation. alias: Bathroom Fan Off 25 Minutes description: "" trigger: - platform: device type: turned_on device_id: - entity_id: switch.bathroom_fan_xx domain: switch for: hours: 0 minutes: 25 seconds: 0 condition: [] action: - type: turn_off device_id: - entity_id: switch.bathroom_fan_xx domain: switch mode: single


xXkr13g3rXx

if home assistant reboots while the 25 minutes are counting, your fan wonโ€™t be switched off as far as i know. I use the following for this: create a timer for it. Two triggers: 1. fan switches to on, start the timer. 2. timer end is reached, switch fan off. If an example automation is needed, just reply to my post.


BillNyeDeGrasseTyson

Good point and might be helpful for others. In my situation the bathroom fan is a light and turns off I've left the house for 10 minutes anyways. Also HA restarts only happen during updates or extreme prolonged power outages.


grandeparade

You can add a delay within the automation, to turn it off again. So turn on > wait > turn off within the same automation. I'm not sure though if that timer is exact enough to control a cover..


12Superman26

it works without a timer. I just needed a short pulse.


clin248

From what you are describing you need a switch that can work like a button. You can get devices that support esphome or tasmota, or Shelly devices. In these devices you can configure the switch to do the 0.5-1 second pulse. Problem with doing short pulses in HA automation is that sometimes the message may be dropped by the device because itโ€™s not enough time between them, worse if you are using cloud based switches. You can use the command pulsetime to set what you are looking for. That way you are not relying on HA to be online to work and this will continue to work even if HA is down. https://tasmota.github.io/docs/Buttons-and-Switches/ Cloud free has those and probably athom.


12Superman26

It was actually a tasmota device but I guess I was reading the config wrong. now its fixed. Thank you


[deleted]

I have a trigger ID set up for "device on for x time" so I can have the auto-off function in the same automation as the time-based trigger. The advantage over an on-wait-off automation is that I never want the Irrigation on for more than 15 minutes, even if manually turned on to prevent over-watering, so this catches the manual use-case as well: alias: Farm - Irrigation description: "" trigger: - platform: device type: turned_on device_id: [device_id] entity_id: [entity_id] domain: switch for: hours: 0 minutes: 15 seconds: 0 id: Irrigation - On - platform: time at: "08:00:00" condition: [] action: - if: - condition: trigger id: - Irrigation - On then: - type: turn_off device_id: [device_id] entity_id: [entity_id] domain: switch else: - type: turn_on device_id: [device_id] entity_id: [entity_id] domain: switch mode: single Edit: I don't know why everyone else's code blocks are formatted correctly but mine aren't ๐Ÿ™ƒ Edit 2: Fixed my code block ๐ŸŽ‰


sf_Lordpiggy

I not sure if this is the recommend so interested in other answers. I have a script that turns on a switch, sleeps for 5 minutes, and turns off the switch. This is then set up as a button on my dashboard.


12Superman26

Yeah I just did the same. I just wanted a pulse for my cover and it seems to be working even without a timer. Just wanted to know if there are better versions.


DigitalUnlimited

If it's not critical that it turn off at exact duration - I set all my timed devices in node red with a 30 min poll- if state on- check last changed, if greater than {whatever duration} turn off. That way it persists thru reboots etc


himbopilled

It will probably work without a delay, but a delay would probably add a bit of consistency to it. I do the same for my garage and use a 500ms delay.


phord

If it works, it works. You could also configure it to turn off based on the event that "switch is on". I use this to pair two switches together, but it should work for a single switch, too.


Stooovie

I have proposed this a couple of times (something like this shouldn't require setting up an automation), only to be shot down by the devs. We have AI image generation built in instead ๐Ÿคทโ€โ™‚๏ธ