Can an input boolean be turned off with an automation without triggering another automation linked to the off-state?

I have 2 automations linked to a input boolean. When toggled on it has some conditions and either exits with a notification or proceeds (it runs when state goes from off to on, no main conditions, action is a “choose” which introduces some logic). When toggled off, it does an action (powers a device off).

So far, this works great. But, in the UI, the toggle is still on. So i added an action at the end of “failed” condition to toggle it back off. However, this kicks off the “off automation.”

Is there a way to set the input boolean back to off without triggering the associated automation with the off state?

What’s the best way to post if i made it in the UI?

Three dots upper right corner, edit in YAML, copy and paste here.

1 Like
alias: Stop KidKam Monitor Mode
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.kidkam_monitor_mode
    from: 'on'
    to: 'off'
condition: []
action:
  - service: media_player.media_stop
    data: {}
    target:
      device_id: 4f65abe485c0eb6a6c8cbeaa3b47d6c0
  - service: media_player.turn_off
    data: {}
    target:
      device_id: 4f65abe485c0eb6a6c8cbeaa3b47d6c0
mode: single

Add a delay at the end and then turn off the input boolean. fi:

     - delay:
          seconds: 5
    - service: input_boolean.turn_off
      entity_id: input_boolean.kidkam_monitor_mode

edit: Sorry, now i understand your question. I dont know how to do it, maybe merging both automations into one…

Automation can be switch off and on using the automation.turn_off and automation.turn_on services.

I have a different usecase, however same problem. Solution, switch off the other automation and then on again when you have changed the boolean. Maybe use a short delay to ensure the has changed.

      - service: automation.turn_off
        data: {}
        target:
          entity_id:
            - automation.name_of_the_automation_entity

Why are you using an input boolean if you don’t want it to act like an input boolean?

I do need it to be an input boolean. I need a “gui switch” to control automations. State on, off. If switched on, do something. If switched off, do something.

So what do you mean in don’t want it to be a Boolean.

If you have a suggestion to make a gui, manual switch to run automations while keeping the switch ui consistent with the outcome, I’m all ears.

I do this for many things but it is manual from the UI. I use an entities card to accomplish this.

Here is my boolean:

input_boolean:
  racktheather:
    name: Rack Control for Theater
    icon: mdi:theater

Then I have two scripts that turn on and off

avracktheater_on:
  alias: Rack On For Theater
  sequence:
  - service: switch.turn_on
    data: {}
    target:
      entity_id:
      - switch.media_room_rack_duplex
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.media_room_vizio_tv
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: remote.send_command
    data_template:
      entity_id: remote.nadz0
      command: poweron
      device: remote.nadz0
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 750
  - service: remote.send_command
    data_template:
      entity_id: remote.nadz0
      command: input1video1
      device: remote.nadz0
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 750
  - service: remote.send_command
    data_template:
      entity_id: remote.epson
      command: poweron
      device: remote.epson
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 750
  - service: remote.send_command
    data_template:
      entity_id: remote.hdmi
      command: gtvtomediaprojector
      device: remote.hdmi
  mode: single


avracktheater_off:
  alias: Rack Off For Theater
  sequence:
  - service: remote.send_command
    data_template:
      entity_id: remote.nadz0
      command: poweroff
      device: remote.nadz0
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 750
  - service: remote.send_command
    data_template:
      entity_id: remote.epson
      command: poweroff
      device: remote.epson
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 750
  - service: switch.turn_off
    data: {}
    target:
      entity_id:
      - switch.media_room_rack_duplex
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: switch.turn_off
    data: {}
    target:
      entity_id:
      - switch.media_room_vizio_tv
  mode: single

Then I have two automations for on/off. I have not gotten around to combining these with triggers.

id: 'XXXXXXXXXXXXXXXXXXXX'
alias: Rack On for Theater
description: When system toggled from off to on run the script to turn on rack in
  theater mode
trigger:
- platform: state
  entity_id: input_boolean.racktheather
  to: 'on'
  from: 'off'
condition: []
action:
- service: script.avracktheater_on
mode: single

id: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
alias: Rack Off for Theater
description: When system toggled from on to off run the script to turn off rack
  in theater mode
trigger:
- platform: state
  entity_id: input_boolean.racktheather
  to: 'off'
  from: 'on'
condition: []
action:
- service: script.avracktheater_off
mode: single

Here is a screenshot of the entities card

Screenshot from 2022-03-26 10-37-54

If you wish it to automatically switch based on time, motion, or presence, then you need hardware and automations to do this. The delays in the script are to prevent overrunning the IR control.

Hope this helps

So Here’s my ui:

When I toggle that switch from off → on, here is the automation it runs:

alias: Start KidKam Monitor
description: >-
  Starts KidKam in an old school monitor mode by streaming the audio from Remote
  Streaming Audio Server (rsas) to the selected receiver (a dropdown input
  helper). 
trigger:
  - platform: state
    entity_id: input_boolean.kidkam_monitor_mode
    from: 'off'
    to: 'on'
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_select.kidkam_receiver
            state: Living Room TV
        sequence:
          - service: media_player.play_media
            data:
              media_content_id: http://192.168.2.27:8001/babymonitor01.mp3
              media_content_type: music
            target:
              device_id: 4f65abe485c0eb6a6c8cbeaa3b47d6c0
    default:
      - service: notify.notify
        data:
          message: >-
            The selected receiver has not been configured in the KidKam Monitor
            Automation. You will need to add a condition to the choose action
            Condition Type: State | Entity: KidKam Reciever | State: <the name
            of the device in the dropdown helper list> 
          title: KidKam Monitor Mode Failed
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.kidkam_monitor_mode
mode: single

The logic here is
When the state of the helper (input_boolean.kidkam_monitor_mode) goes from off to on,
Choose one of the following actions:
Option1: If the state of the input dropdown helper (input_select.kidkam_receiver) is “Living Room TV”, then play_media to that device ID (4f65abe485c0eb6a6c8cbeaa3b47d6c0=Living Room TV)
(I will add more options for all the various receivers around our house, but for now, I was testing with our chromecast tv. )
Default action if no option matches, (i.e. I have a chromecast receiver in my helper list that has not been configured in the actions of this automation) send me an alert and then move the switch back to the off position (this keeps the UI consistent with what’s actually happening around the house).

So I supposed I could just let it continue to run the “off” state automation, as theoretically, it would be benign. But I wanted to get creative, just I case I had other automations for the off state (like lights, alerts, or sounds).

Stop Automation (is only hardcoded to one device right now, no dropdown helper integration just yet:

description: ''
trigger:
  - platform: state
    entity_id: input_boolean.kidkam_monitor_mode
    from: 'on'
    to: 'off'
condition: []
action:
  - service: media_player.media_stop
    data: {}
    target:
      device_id: 4f65abe485c0eb6a6c8cbeaa3b47d6c0
  - service: media_player.turn_off
    data: {}
    target:
      device_id: 4f65abe485c0eb6a6c8cbeaa3b47d6c0
mode: single