Simple Time Monitored Switch

Purpose
Monitor a switch for turning on and turn off after a given delay. Can be used if you want to limit the time a switch stays turned on but you turn on the switch by other means (e.g. manually).

Example Use Case
Always turn off the garden sprinkler system after 30 min, independently how or when it was turned on.

Input parameters

switch target = switch to be monitored (entity in switch domain, no default)
switch delay = turn off delay (formatted as hh:mm:ss, default “00:15:00”)

Other Remarks

  • This blueprint does not turn on the switch, it does only check if a switch is activated (manually or by any other script).
  • The time monitoring will not survive a home assistant restart during the (meaning the switch will stay turned on if the restart occurs during the delay period).

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint by using the forum topic URL (Github Link)

blueprint:
  name: Simple Time Monitored Switch (State Change Triggered)
  description: turn off an activated switch after a specific delay (hh-mm-ss)
  domain: automation
  input:
    switch_target:
      name: Monitored Switch
      description: Switch to be monitored
      selector:
        entity:
          domain: switch
    switch_delay:
      name: Switch Off Delay
      description: Delay to switch off (hh-mm-ss)
      default: "00:15:00"
      selector:
        time:

trigger:
  platform: state
  entity_id: !input switch_target
  from: "off"
  to: "on"

action:
  - delay: !input switch_delay
  - service: switch.turn_off
    entity_id: !input switch_target
          
mode: restart
max_exceeded: silent

If you’re running an older Home Assistant version, follow the following steps:

  • Copy the URL from the browser address bar
  • Go to Home Assistant → Configuration → Blueprints
  • Click on the blue “Import Blueprint” button in the bottom right, paste the blueprint topic URL
  • Click on “Preview Blueprint”
  • Click on “Import Blueprint”

This doesn’t work. The trigger upon automation creation expects another blueprint to run this ???
Disregard. Must have been something wonky in my HA, restarted and it seems to work :slight_smile:

This is exactly what I am searching for.
But import shows a strange behavior:
It says:
“No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.”
No matter what way I use to import.
Could someone check?
Im to stupid to find the reason.
Thx
Rakete

Not sure what caused the failure on the import button. Tried to fix it, but without success so far I think.

It still generates as error:

while scanning a simple key in "<unicode string>", line 32, column 1: </code></pre> ^ could not find expected ':' in "<unicode string>", line 33, column 1: <p>If you’re running an older Ho ... ^

Meanwhile use the Github link, that one seems to work well.

Strange behavior indeed, since the code on Github is the same as in the code block…

1 Like