Display color temp as kelvin in Lovelace?

I feel like I’m missing something in configuration options but I can’t seem to find it, so I’m asking here.

I understand that mireds are the internal unit used for a number of systems, likely due to the ease of representing the value with a single byte (similar to brightness, etc). That’s fine for internal use, but it’d be incredibly helpful to instead display that value as Kelvin in the more-info view when clicking on an entity in Lovelace.

I understand that I can create custom entities or sensors that display this value calculated as Kelvin using a template, but that seems extremely excessive and still does not achieve the task of displaying this in more-info views. I know I can use the secondary-info custom entity card to tack that on underneath the entity in an ‘entities’-esque view, but again, that requires I define a sensor or attribute in config files for every bulb, which becomes quite tedious if I change anything up.

Is this a setting that can be changed for the frontend as a whole, similar to enforcing using Fahrenheit/Celsius or Miles/Kilometers for the units? It doesn’t appear in any visible UI configuration pane and I’m hoping this is something I can set in one spot in my configuration.yaml to set that up.

Any help is greatly appreciated! Kelvin are the standard unit used for discussing color temperatures and I feel should be the default display, with mireds accessible as an attribute.

1 Like

I ended up creating a Node-RED flow for this that updates lights to add the attribute, which then displays in the more-info view. However, at least with my Hue, this is hitting the API every 5 seconds if one’s changed at all, because Hue overwrites the attributes removing the ‘kelvin’ attribute I add, and this counts as a state change which then fires off the flow again.

If Home Assistant can be easily added or changed to display with a simple configuration toggle it’d be far more welcome than trying to modify/extend the Hue integration for this purpose or using this Node-RED flow. But for others who don’t mind a hit to their API every 5 seconds for every time Hue refreshes a bulb that’s changed color temp, this might help.

[{"id":"9ee9f79b.d70b6","type":"tab","label":"Add Kelvins","disabled":false,"info":""},{"id":"561fd539.afcb6c","type":"server-state-changed","z":"9ee9f79b.d70b6","name":"","server":"89832b2d.e18b78","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.","entityidfiltertype":"substring","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":150,"y":60,"wires":[["4feff122.a5b7e"],[]]},{"id":"4feff122.a5b7e","type":"function","z":"9ee9f79b.d70b6","name":"Convert to not-stupid-units","func":"if (msg.data.new_state.attributes.is_hue_group === true) {\n    return null;\n}\nif (!msg.data.new_state.attributes.hasOwnProperty('color_temp')){\n    return null;\n}\nif (msg.data.new_state.attributes.hasOwnProperty('kelvin')) {\n    return null;\n}\nvar mireds = msg.data.new_state.attributes.color_temp;\nmsg.payload =  {\n    \"state\": \"on\",\n    \"attributes\": msg.data.new_state.attributes\n}\nmsg.payload.attributes.kelvin = Math.round(1000000 / mireds);\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":60,"wires":[["c23d7805.ef4f78"]],"inputLabels":["stupid units"],"outputLabels":["sane units"]},{"id":"c23d7805.ef4f78","type":"ha-api","z":"9ee9f79b.d70b6","name":"","server":"89832b2d.e18b78","debugenabled":true,"protocol":"http","method":"post","path":"states/{{data.new_state.entity_id}}","data":"msg.payload","dataType":"jsonata","location":"payload","locationType":"msg","responseType":"json","x":690,"y":60,"wires":[[]]},{"id":"89832b2d.e18b78","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Alternatively an easier way to inject custom attributes that won’t get overwritten by the integration update would help! Sticky attributes, so to speak, or an overlay.