Parse content of a MQTT message

I’m getting a message from my sensor which looks like this:

{‘id’: ‘0’, ‘idx’: ‘0’, ‘alias’: None, ‘platform’: ‘state’, ‘entity_id’: ‘text.solar_fehler’, ‘from_state’: <state text.solar_fehler=00 00; mode=text, min=0, max=255, pattern=None, friendly_name=Solar Fehler @ 2024-10-07T14:46:44.116587+02:00>, ‘to_state’: <state text.solar_fehler=aa 00; mode=text, min=0, max=255, pattern=None, friendly_name=Solar Fehler @ 2024-10-10T15:01:47.361734+02:00>, ‘for’: None, ‘attribute’: None, ‘description’: ‘state of text.solar_fehler’}

This comes from an automation doing

action: notify.persistent_notification
metadata: {}
data:
message: " {{trigger}}"

Now my simple question: how do I parse this string so I get the “aa 00” from the

‘to_state’: <state text.solar_fehler=aa 00

inside?

Are you sure this is an MQTT message?

Based on the persistent notification action you have posted, it looks more like a State trigger or a similar trigger like Numeric State or Device.

{{ trigger.to_state.state }}

1 Like

Oh, for some reason I got no notice. It IS a MQTT message, though one created programmatically. I’ll try the above, but the message only comes sporadically.

Yes, that did the job. Thanks!