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]: HA State Object (state.state / etc.) not working in Template Card

See original GitHub issue

Current Behavior

Configure a Template Card (via GUI or YAML) and setting the optional Entity Parameter. Then trying to use the Home Assistant State Object to make Templating simpler (not having to type out the entity_id every time, etc.) does not seem to work:

grafik

Maybe I’m just doing it wrong, but as far as I can see, it currently doesn’t work.

Thank you!

Expected Behavior

Being able to use the State Object and its properties in the Template Card.

Steps To Reproduce

  1. Edit Dashboard
  2. Add new Mushroom-Template-Card
  3. Set Entity Parameter to any available Entity
  4. Enter the following in Primary or Secondary Information: {{ state.state }}
  5. Save the changes and take a look at the new Card on the Dashboard

Example configuration

type: custom:mushroom-template-card
primary: '{{ state.name }}'
secondary: '{{ state.state }}'
entity: zone.home

Environment

- OS: Raspbian 11 (bullseye)
- HA Core Version: 2022.8.6 (container)
- HA Frontend Version: 20220802.0 - latest
- Lovelace-Mushroom Version: v2.1.3 (via HACS)

Anything else?

State Object Documentation: https://www.home-assistant.io/docs/configuration/state_object

Templating Documentation: https://www.home-assistant.io/docs/configuration/templating/

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
piitayacommented, Sep 8, 2022

0 is considered as false by the template system so it doesn’t render. I saw workaround for this issue but I can’t find her anymore 😅

For templating the doc is here : https://www.home-assistant.io/docs/configuration/templating/ Mushroom expose two additional variables :

  • user (current logged user)
  • entity (defined in the entity field)

I agree, it should be in the template documentation 🙂 https://github.com/piitaya/lovelace-mushroom/blob/main/docs/cards/template.md

0reactions
RoepLukecommented, Sep 8, 2022

For some reason it wouldn’t display the secondary information (current value = 0). I then changed it to “{{ states(entity) ~ ’ Personen’ }}” and then it is displayed.

Other than that it works flawlessly. Lovelace success.png

Is this documented somewhere and i just overlooked it? If it isnt, then where should it be documented?

Thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lovelace card-templater card (Jinja2 card templating in ...
I tried it yesterday and I saw in the dev tools states page that it changed the actual state there. You won't see...
Read more >
Usage - Floorplan for Home Assistant - GitHub Pages
Observe the HA media_player.tv entity for state changes. Action triggers: When the SVG element (i.e. button.power ) is tapped / clicked, call ...
Read more >
Bug listing with status RESOLVED with resolution FIXED as at ...
_* in /etc" status:RESOLVED resolution:FIXED severity:enhancement · Bug:195 ... Bug:1455 - "USE broken: -item in USE enviroment variable does not work" ...
Read more >
RomRider/apexcharts-card - GitHub
A Lovelace card to display advanced graphs and charts based on ... Eg: if the state is 345 and as_duration is set to...
Read more >
Cisco Firepower Release Notes, Version 6.4 - Security
Open and Resolved Bugs. ... Users not showing correctly in FDM Events ... mode flow table memory usage to reduce the probability of...
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