I recently added the following action as the first of multiple additional steps in an existing automation:
wait_for_trigger:
- platform: state
entity_id:
- media_player.vlc_telnet
to: idle
for:
hours: 0
minutes: 0
seconds: 0
timeout:
hours: 0
minutes: 6
seconds: 0
milliseconds: 0
The media played in VLC by the previous action is ~5:32 and played successfully each time this automation triggered until I added this wait to do more things after it finishes playing. No HAOS component version changes occurred between the normal instance and this odd one.
Before I added the wait to the automation, the VLC logbook entries looked like this:
First, when an automation would run:
VLC-TELNET changed to Playing triggered by automation Wake 2 triggered by time set in Wake 2 Time
Next, when the media stopped playing (by reaching the end of the file or me triggering a script that stops the player [tens of seconds to minutes later]):
VLC-TELNET changed to Idle
After I added the additional action to the automation, the logbook entries looked like this:
No change to the first entry when an automation would run:
VLC-TELNET changed to Playing triggered by automation Wake 2 triggered by time set in Wake 2 Time
Two seconds later before I was even aware the media was playing:
VLC-TELNET changed to Idle triggered by automation Wake 1 triggered by time set in Wake 1 Time
This is all set up via lovelace, so the relevant part of the Actions
section in the automation looks like this in the visual editor:
Play media on VLC-TELNET
Wait for 'When VLC-TELNET changes to Idle'
The first action shown here is unchanged from when the automation worked, and the second one is new, matching the YAML at the beginning of this post. At first I was concerned that the “wait” was actually a “trigger and wait” but I searched and now believe the automation is configured correctly based on Wait for sequence to finish - #2 by 123 being a confirmed solution to something similar to what I was attempting.
The logbook entry makes it look like that action must have caused the media player to switch to idle, but I’m not sure if that’s actually what happened. There was also a notification that a login failed due to a bad password, and that notification seemed to imply that VLC-TELNET is what failed to log in. Unfortunately, I dismissed it before getting a screenshot or copying the text.
The relevant section of the trace timeline doesn’t appear to provide any additional useful information, but it looks something like this:
| *Play media on VLC-TELNET
|
| °(media_player.vlc_telnet) turned playing
|
| *Wait for ‘When VLC-TELNET changes to Idle’
|
| 2 seconds later
|
| °(media_player.vlc_telnet) turned idle
I can wait to see what happens next time this automation triggers in case this time was a fluke, and I can update this thread accordingly, but I wanted to go ahead and post this in the interim for a chance to get any insight on what may have happened and where I may need to look to prove it.