MQTT state_topic is year depending, do not want to hard code

Hi, I have a state_topic that contains year(s) and I would like to create a sensor for that wihtout hardcoding the year. I searched a bit and understand that the state_topic does not accept templating … are there any ‘simple’ alternatives to get this value extracted?

myelectricaldata/xxxxxxxxxxxx/consumption/annual/2024/thisYear/base/Wh

image

Just a guess, i don’t have such topics to test, but have you tried:

myelectricaldata/xxxxxxxxxxxx/consumption/annual/+/thisYear/base/Wh

Assuming only the topic with the current year changes

1 Like

Really nice and many thanks. I would love to know where I could learn these ‘tricks’…any links you could share?

1 Like