How to raise an alert when a zigbee error message is received?

In most of the issues I have with my zigbee devices or network there is some error message in the zigbee2mqtt log (starting with zigbee2mqtt:error), is there any way to trigger an event in Home Assistant every time an error happens so I can get an alert? That would give me a heads up instead of the current reactive mode where I first have to realize something is wrong and then I check the logs

You could create a sensor that listens to zigbee2mqtt/bridge/log

That´s exactly what I was looking for, thank you!!

Hi, how did you solve this? By having a sensor listen to the logging messages, I get errors that State max length is 255 characters. Do you pick only parts of the message?

I use node red so I created a MQTT node to listen to the messages from topic zigbee2mqtt/bridge/log and then a json node to extract the info:

Do you mind sharing the code extract for this? I will need to try to do this with a template sensor.