I want to create an automation that switches a device off if turned on by any method other than an automation. I have a pump that I only want to run when the daily automation triggers it as there is a possibility for the device to be manually turned on outside of home assistant. If this occurs, I want to automatically switch the pump off. I have seen info on conditions for the auto off automation, but im struggling to trigger this condition based on a ‘not’ command.
Any ideas?
To add more context, each of my automations that I want to be able to turn the device on, use a helper button, so the trigger is a button press either by the UI or by a secondary automation that schedules a button press. I believe if I set a condition that means anything else that turns the pump on will result in the pump turning off other than the push buttons, then I would achieve what I want.
Worked it out:
alias: Auto off chlorinator
description: ''
trigger:
- platform: state
entity_id:
- switch.pentair_chlor
from: 'off'
to: 'on'
- platform: state
entity_id:
- input_button.add_per_input_box_cup
- platform: state
entity_id:
- input_button.add_per_input_box_gal
- platform: state
entity_id:
- input_button.morning_chlorine
- platform: state
entity_id:
- input_button.afternoon_chlorine
condition:
- condition: not
conditions:
- condition: state
entity_id: input_button.add_per_input_box_cup
state: ''
- condition: or
conditions:
- condition: not
conditions:
- condition: state
entity_id: input_button.add_per_input_box_gal
state: ''
- condition: or
conditions:
- condition: not
conditions:
- condition: state
entity_id: input_button.morning_chlorine
state: ''
- condition: or
conditions:
- condition: not
conditions:
- condition: state
entity_id: input_button.afternoon_chlorine
state: ''
action:
- service: switch.turn_off
data: {}
target:
entity_id: switch.pentair_chlor
mode: single