Calendar: Search/replace in event title

Hi
I am using the AULA integration (Danish school information app) which adds calendars for each of my kids.
Their daily school schedule is created as a calendar sensor and I can display it in a card with:

type: calendar
initial_view: dayGridDay
entities:
  - calendar.skoleskema_name

This provides the following output:

What I would like to do is run a search and replace on the title so that “DAN” is replaced with “Dansk”.

I have tried with the following code but it does not work :sob:

type: calendar
initial_view: dayGridDay
entities:
  - calendar.skoleskema_name
eventTemplate: |
  {{ event.title 
  | replace('m.samling', 'Morgen samling')  
  | replace('DAN', 'Dansk') 
  | replace('MAT', 'Matematik') 
  | replace('BIB', 'Bibliotek') 
  | replace('IDR', 'Idræt') 
  | replace('ENG', 'Engelsk')  }}

Any pointers would be very welcome.

Thanks
/Palle

The Calendar card simply displays the information from calendar.skoleskema_name.

The card’s options are explained in its documentation. There’s no setting or YAML option to rename a calendar event.

Because to eventTemplate is not a valid option.

aha, that explains alot :thinking:

Thanks

Did you find a solution, i have same problem

I am looking to do the same thing here … Anything to report on that has worked?

Sorry for the late reply.
I did find a (nasty?) hack-a-round…

For the AULA integration, the information is stored in /config/skoleskema.json
The file is updated very often from the AULA integration (every minute’ish)

I run a rasberry Pi, so i wanted to minimize disk writes.
I installed spook (in HACS) and created 2 automation.
the first enables the AULA integration at 06:00.
The second disables the AULA integration at 06:15 AND executes a shell command.
(prepared in my config.yaml)

(reduced the shell command, because it’s REALLY big with three kids ;))

shell_command:
  skoleskema: |
    sed -i 's/\\"teacherInitials\\":\\"AJ\\"/\\"teacherInitials\\":\\"Anne Jensen\\"/g;
    s/\\"teacherInitials\\":\\"AJ\\"/\\"teacherInitials\\":\\"Arne J\\\\u00f8rgensen\\"/g;
    s/\\"title\\":\\"IDR\\"/\\"title\\":\\"Idr\\\\u00e6t\\"/g;
    s/\\"title\\":\\"MAT\\"/\\"title\\":\\"Matematik\\"/g;
    s/\\"title\\":\\"MUS\\"/\\"title\\":\\"Musik\\"/g;
    s/\\"title\\":\\"TYS\\"/\\"title\\":\\"Tysk\\"/g' /config/skoleskema.json

Also, æ, ø, å, Æ, Ø and Å should be replaced by… I looked it up in the original skoleskema.json file.

Hope this helps.

/Palle