I’m not sure if my problem is the same, but I’ve found custom:button-card seems to be fairly broken with respect to attributes.
Take the following example, you can see a standard entity card beside the identical custom:button-card showing completely different data. In some cases I can’t even work out where the data is coming from, it’s not the entity and it’s not the attribute. In a few cases it’s using wording I can’t even find in dev-tools.
@ashscott I think your issue is with integers in your IF statement here.
if (states['climate.central_heating'].attributes.hvac_action = "heating")
and (states['sensor.central_heating_socket_power'].state < 300)
return 'rgb(3, 123, 252)';
// blue
if (states['climate.central_heating'].attributes.hvac_action = "heating")
and (states['sensor.central_heating_socket_power'].state > 400)
return 'rgb(252, 86, 3)';
// orange
]]]
Try this, I don’t have a thermostat configured my HA so I didn’t test it.
[[[
if (states['climate.central_heating'].attributes.hvac_action == "off")
return 'white';
if (states['climate.central_heating'].attributes.hvac_action = "idle")
and (states['sensor.central_heating_socket_power'].state | int < 10)
return 'rgb(3, 123, 252)';
// blue
if (states['climate.central_heating'].attributes.hvac_action = "heating")
and (states['sensor.central_heating_socket_power'].state | int < 300)
return 'rgb(3, 123, 252)';
// blue
if (states['climate.central_heating'].attributes.hvac_action = "heating")
and (states['sensor.central_heating_socket_power'].state | int > 400)
return 'rgb(252, 86, 3)';
// orange
]]]
Here’s another example of completely inconsistent data compared to the sensor attributes I can see elsewhere. In some cases they make no sense, in others it’s more useful (like “locked int” tells me it was locked from the inside, but I cant see thay info if I look at the sensor attributes.
I’m not sure I understand what you mean. I only want to display attributes for the sensor.
When I display them all using an entity card they display fine, which is solely there to show that the attributes exist and work, I’d never normally display the same thing side by side. So, left hand side is purely for debugging and showing the attributes exist and display correctly. Right hand side is button card, and not displaying attributes correctly (despite using the same method to display the volume attirbute for some of my other cards elsewhere successfully).
What I’d expect to see is that the right hand side data mirrors the left… which is not happening.
Thanks @LiQuid_cOOled. I understand you can’t use the same sensors, but it’s making it difficult for me to interpet what I’m doing wrong from your examples.
If we ignore the cards for a second, I have a single sensor (car_locked) that is showing me different data in different situations. My issue is working out how to get it to show what I want in button card. Based on guidance for a different scenario (volume for an amplifier state) I’d been using the state_display function… but perhaps Im going about it all wrong.
the second pic is the actual device correct? Let’s switch to DM so you can share the device entity name. I see what the issue is now. Your pics help enormously
Thanks Liquid, I replied directly. I think I am using the correct entity, but it is definitely a little odd and might be due to the car manufacturer doing something weird, or the custom component thats getting it into HA.