Is it possible to have an automation triggered by an event created in Logbook.Log? The documentation isn’t clear, and I’ve not been able to get it to work.
From an action:
…
- service: logbook.log
data_template:
name: test_event
message: test message
…
In an Automation:
…
trigger:
event_data:
message: test message
event_type: test_event
platform: event
…
The automation never fires.
Or, is there a better way to raise an event that an automation can respond to? I’m aware you can directly trigger the automation using automation.trigger, but it appears that ignores conditions on the automation.
What exactly are you trying to do… and what does the automation that wasn’t working look like?.. the whole thing. Also be sure to format your code properly using the </> button.
I haven’t written the whole automation until I can figure out this piece. I thought I could use this as a means of looping for repeated notifications when my vacuum stops in a bad state. I.e., have:
Automation triggered by vacuum state change OR a custom event
Condition: vacuum state not charging and not running
Action: Run script
This was easier than I expected, and I ran across the solution when working on something else. I got it working by using a timer. I’m a little disappointed no one could suggest it. Here’s what I did in case it helps someone else.
First, I have a sensor to give me more details on my vacuum state:
and the timer:
timer:
roomba_reminder:
name: Roomba Issue Repeat Timer
a script formats the notification with the current status:
roomba_status_announcement:
alias: Roomba Status Annoucement
sequence:
- service: script.turn_on
entity_id: script.home_audio_annoucement
data_template:
variables:
message: Roomba alert!..The Roomba has a current status of {{ states(‘sensor.roomba_status’) }}…Repeat, the Roomba has a current status of {{ states(‘sensor.roomba_status’) }}.
And finally, the automation, which files on any state change OR the timer fires
alias: Roomba Problem Notification
trigger:
- entity_id: sensor.roomba_status
platform: state
- event_data:
entity_id: timer.roomba_reminder
event_type: timer.finished
platform: event
condition:
- condition: and
conditions:
- condition: template
value_template: ‘{{ not is_state(’‘sensor.roomba_status’’, ‘‘Charging’’) }}’
- condition: template
value_template: ‘{{ not is_state(’‘sensor.roomba_status’’, ‘‘Running’’) }}’
- condition: template
value_template: ‘{{ not is_state(’‘sensor.roomba_status’’, ‘‘End Mission’’)
}}’
action:
- service: script.roomba_status_announcement
- data:
duration: 00:10:00
entity_id: timer.roomba_reminder
service: timer.start
Ugh, and for some reason the </> button only worked on the first section. But hopefully you get the idea:
Set up a timer
Set up an automation that triggers on the state change and the timer
The automation has conditions to not run under “good” states
The automation does your notification and sets the timer to running
Any success in accessing the logbook entries? This is how I would like to use the logbook but I don’t know how to start - any thoughts would be greatly appreciated. Here’s my scenario: If I am leaving the house using the front door because I left my car parked on the drive way and the garage door is closed. So when I drive away from home I can use the latest entries of the logbook to determine if the front door was opened and when I drive away and trigger zone entries, I would be able to see that I left through the front door and I do not have to trigger to close the garage door. Am I making this too complicated? I use Node-Red more frequently than yaml but i can work with either also I am using the Traccar addon. Thanks in advance
I could do with having a log entry as a trigger if someone’s figured it out. I have a sensor polling a really flaky instance of apcupsd on another server, which keeps crashing. I’ve never been able to fix it but it would be really useful as a workaround to code an automation that can detect the “Updating apcupsd sensor took longer than the scheduled update interval” entry and send a service restart command.