question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Template not rendering in template card

See original GitHub issue

Current Behavior

The template doesn’t consistently render. It usually just shows the template text itself.

Expected Behavior

The template renders to show 0 guest devices connected, 1 guest device connected or X guest devices connected.

Steps To Reproduce

type: custom:mushroom-template-card
primary: guest_ssid
secondary: >-
  password

  {% set dev_count = states.device_tracker | selectattr('state', 'eq', 'home') |
  selectattr('attributes.essid', 'eq', "guest_ssid") | list | count %}{% if
  dev_count == 1 %}{{dev_count}} guest device connected{% else %}{{dev_count}}
  guest devices connected{% endif %}
icon: mdi:wifi-lock
multiline_secondary: true
  • Set up a template card using this YAML (YAML not necessary, just easier to share).

Environment

  • OS: macOS 12.3.1
  • Browser: Safari 15.4 / Home Assistant Companion App for macOS / Chrome 102.0.5005.61
  • Version: v1.9.0 (HACS)
  • Hassio: 2022.6.3
  • Template attributes from: UniFi Network

It doesn’t really matter what I use. Not been able to find a match between when it does render and when it doesn’t though.

Anything else?

Screenshot 2022-06-07 at 19 51 54

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
caraar12345commented, Jun 9, 2022

~Just to close the loop, this is the cursed thing I’ve had to produce to make sure it works 😂~

It did not work…

{% set devices = [] %}
{% for entity in states.device_tracker %}
  {% if 'essid' in entity['attributes'].keys() %}
    {% if 'guest_ssid' in entity['attributes'].values() %}
      {% set devices = devices + [entity] %}
    {% endif %}
  {% endif %}
{% endfor %}

{% set dev_count = devices | list | count  %} 


{% if dev_count == 1 %}
  {{dev_count}} guest device connected
{% else %}
  {{dev_count}} guest devices connected
{% endif %}
0reactions
caraar12345commented, Jun 7, 2022

Lol nor am I unfortunately. I think it’s because device_tracker doesn’t exclusively cover the UniFi entities so it might be something about whether it comes across a UniFi entity first or not. Will have a play!

Cheers and sorry again 😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Templating] Adaptive Card is not rendering, when binded ...
Platform Template engine, all platforms Is your feature request related to a problem? Please describe. If the data is not binded to ...
Read more >
Solved: Adaptive card not rendering in teams
Hey folks, I have an issue where the post of an adaptive cards (approval) into Teams isn't rendering properly -- it's just posting...
Read more >
Django Template not rendering - python - Stack Overflow
I am trying to load a list of objects from a MySQL database using Django templates. I can load the objects ...
Read more >
LWC Not Rendering in Record Page, No Error Appears
I'm trying to build a Google Maps LWC to show the location of an Account on the Account's record page. However, the component...
Read more >
LWC component not rendering - Salesforce Stack Exchange
I've confirmed the apex works by running it in the dev console. Here is the code: Apex public without sharing class postController {...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found