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?
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.
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.
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
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.
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: