Device_id('...') not working for zha_event trigger

Hello

I have a working automation that uses an event trigger to listen for zha_events on a specific device_id.

I want to turn it into a blueprint to make it reusable for different devices, however I can not make the trigger works with templates

But when I try in the developer tools, the template gives the right value: screenshot

I am doing something wrong?

I think the cause of your issue is that Event triggers only support Limited templates and device_id() is likely not part of that… You can move the template to a Template condition, where a wider range of template functions are allowed.

trigger:
  - platform: event
    event_type: zha_event
condition:
  - "{{ trigger.event.data.device_id == device_id('switch.example')}}"
action:
....

Works perfectly, thanks you!