Closed luixal closed 1 year ago
Replace the mushroom with a conventional card, your custom sensor with a standard "sun.sun" - and see if it works:
So, probably not related to CTC card. Check your mushroom (what values may be accepted by that option), check your sensor's attribute.
Got it!
I posted this issue here because following the errors and making tests with the mushroom card it felt like the mushroom card wasn't getting a valid value. And THAT was the problem, but not really a bug in config-template-card.
The entity's attribute has a boolean type (true/false) and the mushroom card expected a string in the primary
field. Just passing the boolean as string did the trick:
type: custom:config-template-card
variables:
VALUE: states['binary_sensor.irrigation_unlimited_c1_m'].attributes.enabled
entities:
- binary_sensor.irrigation_unlimited_c1_m
card:
type: custom:mushroom-template-card
entity: binary_sensor.irrigation_unlimited_c1_m
primary: "${ VALUE.toString() }" // <--- NOTICE THIS
icon: mdi:water
icon_color: blue
if anyone gets here and wants to make it a little bit nice, you can use this:
primary: "${ VALUE ? 'Enabled': 'Disabled' }" // <--- NOTICE THIS
Cheers!
Checklist:
Release with the issue: 1.3.6
Last working release (if known):
Browser and Operating System: Chrome 112.0.5615.165 running on EndevourOS (Arch Linux)
Description of problem: I'm trying to use config-template-card with mushroom cards and everythings works fine as long as I use values in the state object at a root level, when I try to get values from attributes it seems that a null value is passed.
This example works and happily renders sensor's state:
If I try to show the value from an attribute, like this:
It fails and nothing is rendered.
Javascript errors shown in the web inspector (if applicable): The error I get in browers console is related to the mushroom card:
and I guess it is produced because the mushroom card expects that value to not be null.