I’m trying to create an automation but hitting some brick walls. My aim is to have the automation run when a google calendar event contains ‘Red bin day’ for example, as the title.
I would then like to ‘post’ a message via MQTT that contains the calendar event title to my AWTRIX flashed clock.
You should probably change your condition to be based on the trigger variable instead of the calendar entity. The state of the calendar entity is not reliable if you ever have overlapping events in the calendar.
Having tried that the trigger happens but then the and if on the trigger calendar summary doesn’t appear to work.
I saw another one of your comments on another post saying to try the persistent notification to see if it’s passing correctly and it does. But in the automation it either fails at the and if or the then do element. I’m not sure which or if there’s a way of testing each element.
I pressed the 3 dots to test the and if but it says condition did not pass. Not sure if that’s because it’s based on a trigger that hasn’t;t technically been run thus no calendar event? Or something else?
UPDATE:
I tried looking at traces, not knowing too much about them but they showed the error “ Error: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘calendar_event’”
i changed the then do text just to “123” and that passed through to my Awtrix clock fine. So it looks like it’s something to do with passing the {{ trigger.calendar_event.summary }} into the MQTT text?
END UPDATE
I used Digeridrew’s suggested code which all works other than passing the calendar event to my awtrix clock. As per my updated commment above. Showing the error.
Turns out I just needed “ “ around {{ trigger.calendar_event.summary }}
To take this a step further I’m thinking about 2 things that hopefully one of your knowledgeable folk will be able to help with.
Instead of == can i do contains?
I have a blueprint that displays the weather, moon phase etc as an ‘app’ on the AWTRIX flashed clock which appears within the cycle of apps on the clock around 9:30pm for around 60 minutes.
I would like this message to do similar. As opposed to just currently display for 150 seconds. I’d like it to rotate in / out of the display for 1-2 hours. As it’s not always guaranteed I’ll be near my clock. Hope that makes sense
Thank you for this. I do code (web stuff so html/ xsl / css/ less etc) for my job but never yaml so didn’t think a simple contains would be the answer! What language code is this similar too?
The blueprint, I hadn’t realised has it’s own automation yaml code with it, it’s quite extensive so not sure the best way to share /even if you have time to explore (‘just let me know obviously absolutely fine but would rather not be hanging on haha). It is this blueprint.
As complex as that looks, the actual automation part of it is relatively straight-forward. All it should take to add your action is to use the “Take control” option from the 3-dot/expansion menu at the top right when editing the automation. This will convert the blueprint-linked automation into a stand-alone automation and you can add your MQTT publish action.
But, since you will not be relying on the Calendar trigger, you will need to decide how you want to store the payload data for the Weather, Moon automation to retrieve it. If the json string of payload will always be less than 255 characters you can store it in an Input text helper… just add an input_text.set_value action to your existing automation:
Here’s hoping you might get a ping. I’ve had it running for a while now and it’s great
Update time … I’m thinking it’s be even better if it could collect all my calendar events for the day and display them. No matter the time it starts or the name etc. any idea if that’s possible. I couldn’t fathom it out over the past few days.
Can you expand on the idea, it’s not clear to me exactly how you’re visualizing it should work.
For example, should it still trigger 30 minutes before the start of the calendar events, but cycle through the days remaining events instead of just showing the upcoming one? That’s seems do-able. I don’t have an Awtrix, so I’m not 100% versed in how it handles the flow of what it displays, but I’m sure we could figure it out… it just might take some experimenting.