I am building an automation that will use various Conditions to alert me if a door is open or unlocked.
alias: Door-Checker
description: ''
mode: single
trigger:
- platform: device
device_id: ''
domain: ''
entity_id: ''
condition:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.konnected_1c57f2_side_door
state: 'on'
- condition: state
entity_id: binary_sensor.konnected_1c57f2_basement_rear
state: 'on'
- condition: state
entity_id: binary_sensor.konnected_1c57f2_kitchen_door
state: 'on'
- condition: state
entity_id: binary_sensor.konnected_1c57f2_front_door
state: 'on'
action:
- service: tts.google_translate_say
data:
entity_id: media_player.master_bedroom_display
message: A door is Still Open
This doesnât work since there is no trigger.
What I would like is to have my Bedtime Script call the Door-Checker automation.
How do I add the Door-Checker automation to the existing Bedtime script executed by the Lovelace Button? Or⌠can I add the Door-Checker conditions to the Bedtime script?
An automation without a trigger is not an automation.
If your application has no need for a trigger, create a script. Scripts can contain conditions and service calls, delays, choose, repeat, etc. In other words, everything an automation can contain, minus the trigger.
Like @123 says, what you are doing when you create a trigger-less automation is basically a script that wonât run on its own but rather need to be forced to run using automation.trigger, so you might as well make a script. Otherwise you will have to add a service call to automation.trigger to run it.
For my wake-up and sleep modes I use a fairly long script that runs through the laundry list of lights to turn off, lights to turn on and a myriad of other things. While possible inside the automation UI it would be messy (to me at least).
asleep:
alias: Asleep
icon: mdi:home
sequence:
# --------------------------------------
# TURN OFF MOTION AUTOMATION SO THE OFF
# DELAY IS CANCELLED IF TRIGGERED
# --------------------------------------
- service: automation.turn_off
data:
entity_id: automation.trigger_bedroom_motion_when_awake
# --------------------------------------
# TURN ON BEDROOM
# --------------------------------------
- service: homeassistant.turn_on
data:
entity_id: group.bedroom_core
...
# --------------------------------------
# SET STATUS
# --------------------------------------
- service: input_select.select_option
data:
entity_id: input_select.sleep_mode
option: "Sleeping"
mode: single
Why donât you put those condition as triggers? You donât even need the âorâ condition, whenever one of the binary_sensor state is âonâ itâs gonna do the action
Even that wonât work since that service only works with an automation (hence the name) and you canât create an automation without a trigger (you will get errors that says that the trigger is missing) so there is no automation to use that service against.
Iâm not looking for a door chime, the requirement isnât to alert when a door is open.
The requirement is an automation that runs only once, when I lick a button on a Lovelace panel, that tells me if any doors are open at that point in time, and only then.
I already have a button, and I already have a script. I think my take-away from this thread is just to move this door alerting logic into that script somehow, so I just have one giant bedtime script.
If you want to use an automation âwithoutâ a trigger, you can use an input_boolean as helper.
Setup an input_boolean.bed_mode, and use that as trigger in the automation (trigger state input_boolean to on). Whenever you switch that button on, your bed mode starts.
Iâm using this for different modes, one of them is bed mode. I let this bed mode end together with the alarm clock time from my mobile phone. This can be useful if you have for example a coffee machine, that needs to be started before you wake up.
I configured this automation in my automation_test.yaml file (I split mine up with !include and never use the editors):
- alias: test repeat till count
# trigger:
# - platform: state
# entity_id: switch.boot_dryer
# to: 'on'
action:
- repeat:
count: 4
sequence:
- delay: 2
- service: light.toggle
data_template:
entity_id: light.comp_corner_lamp_1df9
The config validator check returns âvalidâ but I also get an error in the logs along with a persistent notification pop-up in the sidebar:
Invalid config for [automation]: required key not provided @ data['trigger']. Got None. (See ?, line ?).
And the automation doesnât show up in my states page.
What is an âaction-groupâ. Is that just the alias of the automation you gave it?
And how did you add the actions for the automation? I donât see those listed.
EDIT:
I just tried it with the automation editor and it does actually work the way you say yours does.
BUTâŚ
I canât imagine that is the intended behavior. Itâs likely a (happy in your case) bug in the system.
So I wouldnât necessarily be recommending that to other users since itâs definitely not consistent between yaml and UI. That will cause way more confusion among users.
Itâs best just to keep the âaction only automationâ as a script and then call that script properly within the lovelace UI or via an automation.
EDIT2:
How in the heck does a person delete an automation created via the UI editor?