Lovelace Card and Jinja

Hi community,

I’m trying to configure a very simple “entities card” able to dynamically show the list of connected devices in my LAN.

I’m using the nmap device tracker.
When I exploit the developer tool for Jinja template elaboration, I’m able to obtain the list of entities id thanks to the following lines of code:

type: entities
title: MyConnectedDevices
entities: {{ states.device_tracker | selectattr('attributes.scanner', 'eq', 'NmapDeviceScanner') | map(attribute="entity_id") | list }}

this is the output:

type: entities
title: MyConnectedDevices
entities: ['device_tracker.XX_XX_XX_XX_XX_01', 'device_tracker.XX_XX_XX_XX_XX_02'', 'device_tracker.XX_XX_XX_XX_XX_03']

When I try this stuff into the Lovelace card configuration I receive this error: " missed comma between flow collection entries at line 3, column 96: … nner’, ‘eq’, ‘NmapDeviceScanner’) | map(attribute=“entity_id”) | … ^ "

Could you please tell me if it is right to insert Jinja templates into lovelace card configurations? If yes, where is the error?

Thank you very much for the support!

Lovelace does not support templating.

There are two custom cards that add this functionality. One jinja, one JavaScript. Go with the javascript version. It has less of a performance impact.

1 Like