Get State of message in Google Calendar with a part of mesaage only

Hi, have anyone an idea, how to solve this: I wont to get the state, if the command is a part of the message only:

Blockquote

{% if states.calendar.mivoh.attributes.message == “Whizzkids im MuZ” %}
On
{%else%}
Off
{% endif%}

Blockquote

In this case MuZ only. The hole message works, but not with “MuZ” only
Thanks in advance for a solution of this
Regards John

For partial matches you can use the in test or search().

{% if 'MuZ' in state_attr('calendar.mivoh', 'message') %} 

or

{% if state_attr('calendar.mivoh', 'message') is search('MuZ') %} 

The search() method also allows ingnoring the case of the letters by adding the argument ignorecase=true.

That is it. Thanks for your quick help and Response…
Regards John

For the search methode where do i put the “ignorecase=true”

{% if state_attr('calendar.mivoh', 'message') is search('MuZ', ignorecase=true) %}

Now works fine… Thanks again

Can this be used in an automation? I have multiple calendars for a vacation rental. Each calendar Message state uses the word Reserved. I was looking to use that word instead of creating multiple conditions to math each message exactly.

The goal of the automation turns on and off the ductless HVAC units. The problem is the calendar gets entries on days not booked but blocked off in between stays. The current automation can’t differentiate between those events.

Yes, but depending on the details of your calendar, automation, and specific use-case you may need to employee methods other than directly searching values from the calendar entity’s state object.

It would likely be best to start your own thread and include a detailed description of the situation/problem as well as any related automation or script configuration.