Hi, I’ve never coded with python/jinja before and I’m trying to learn as I go. I’m using the google calendar integration and I have two types of appointments, ones at 12pm and ones at 2pm. I want to create a trigger to alert me of an upcoming calendar event but want the offset to be dependent on the time of the appointment.
Your template returns nothing if the attribute is not 12:00. How are you “creating a trigger” and what is the 2 for? If this is an automation trigger, and you have confirmed the attribute’s content, you want:
trigger:
- platform: state
entity_id: calendar.khisanthax_gmail_com
attribute: start_time
state: '12:00'
I was using: {{ state_attr('calendar.khisanthax_gmail_com', 'start_time') }}
and I didn’t realize it was giving me: 2024-03-22 14:00:00
So, I used
{% if state_attr('calendar.khisanthax_gmail_com', 'start_time')[11:16] == '12:00' %}
And the split matched what I was inputting. So, no, what I was using was not actually matching. Sigh, a lot to learn.
The 2 was just an output so that in the developer tools /template I could see if it was actually matching true or not.
I was trying to create a variable for the offset time in trigger for a calendar event (if that’s said right). I realize that it’s not that useful but I really wanted to do it more for learning. This is what I ended up with: