I have 2 different automations I am working on that I am looking for guidance. To explain, I am taking a google calendar and using the calendar events to broadcast (tts.google_translate_say) to my speaker devices what the calendar event is. That way I can hear when an event is coming up when I am in my home.
The yaml:
alias: Test
description: ""
trigger:
- platform: calendar
event: start
offset: "0:0:0"
entity_id: calendar.home_assistant
condition:
- condition: state
entity_id: calendar.home_assistant
attribute: message
state: test
action:
- service: tts.google_translate_say
data:
entity_id: media_player.home_assistant_group
message: Test calendar automation from home assistant
cache: true
mode: queued
max: 50
Situation 1:
I would like to be able to look at entity_id: calendar.home_assistant and have the automation read what the event attribute: message is, and just TTS announce what it is and be done with it. My issue is that I am unsure how to do this. Currently, I have a condition set up that looks for the exact name of the event (in this case, state: test), and if it matches, then it performs an action and does TTS on a custom message I write. My default knowledge tells me I should store the attribute: message to a variable, and have the action message announce this variable. Is that the correct way to do that? How would you then store it to variable? Basically I want to announce every calendar event that calendar.home_assistant has inside it because I will have events for Home, Work, and Games. If I can do this, I won’t have to create 3 automations, and I can just have 1 which covers any events listed on this calendar.
Situation 2:
For calendar events, the title of the event in google calendar is the messages state. So I am wondering how I can look at:
state: testing
and write something to check if the state CONTAINS a string in it. Currently, based on the above, it is only going to match the condition if the state is exactly “testing”. I want to be able to check if the state CONTAINS the string “test”. That way I can capture any event with “test” in it", because I may have events where the title says “tested” or “testing”.
Oh, weird. Are you up-to-date? I think some of the endpoints changed in the last few months. That link should just link to whatever URL you’ve specified + the endpoint for the given page (i.e. http://homeassistant.local:8123/developer-tools/state in my case):
In any case, I think it should work for anybody running a standard setup that is fairly up-to-date. Definitely good to know that it doesn’t work for everybody though!
So you’re saying this is more correct? Having a condition of the MESSAGE state being ON for the ENTITY so it can progress through the automation to TTS and start the ACTION?
Because right now I see the automation trigger, but the action never starts.
How can I set the condition state to match anything so that way it will work with any calendar event I make? Right now it’s only looking for calendar events that I name “test”. Is there a way to set it so that it doesn’t matter what the state is set to? aka: it will do any calendar event i make.
Basically just this here. Is there a wildcard I can set for the condition state? Unless I don’t need to specify a condition? But I did try that and didn’t see any TTS happening.
If it is being triggered but you still aren’t hearing the TTS, you can check the trace by clicking on the relevant automation and then clicking “Traces” in the top right. You should be able to check each step for errors from there.
It may be helpful to simplify the automation as well while debugging it. You could try updating a helper with the current time instead of of calling the TTS service, or just making the TTS service call message something like “test”. This just helps debug pieces of it, so you don’t get focused on the trigger when the issue is actually with the service call or something like that.
Also, not sure if just a copy-paste error, but your mode is invalid.