How can i build a toggle for switch a Automation on / off

Hello
How can i build a toggle switch to switch a automation on/off?

Use an input boolean:
https://www.home-assistant.io/components/input_boolean/

I just add them to a tab in the front end.

2 Likes

Here’s an example of mine using an input boolean as the toggle:

- alias: "Camera 2 Zone 4 Motion Detected"
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: input_number.times_motion_cam2_zone4_triggered
  condition:
    - condition: time
      after: "07:00:00"
      before: "19:00:00"
    - condition: state
      entity_id: input_boolean.motion_detection_alerts
      state: "on"
  action:
    - service: script.turn_on
      entity_id:
        - script.xiaomi_gateway_sound_amuse
        - script.cam2_zone4_alert_sequence_notification

So we’re not turning the automation on or off, just adding a condition to when it can be triggered.

It’s the handiest way I reckon.

2 Likes