I’m trying to convert a familiar human readable colour name (like ‘Red’) into HS values.
All the logic is sitting in HA core (https://github.com/home-assistant/core/blob/af5fd74d6f936b159dd06cd19770110ea0dd3d7e/homeassistant/util/color.py) but I cant see a way of getting at it from automation or script land…
A (very hacky) workaround (that I’m using) is to create a template light, set it’s colour with light.turn_on and specify the colour_name then read back the hue/sat values. The problem with that is it clearly creates a race condition on reading the values if you overuse this mechanism - and I really don’t want to create a whole bunch of fake lights per possible context.
The use case that I’m trying to solve is a colour is selected (by a human) from the usual CSS colour names (which work in all sorts of front end interfaces and can be spoken and read back through tts) - that is passed to a script that then mathematically manipulates colours to create interesting lighting effects across a group of lights (say by graduating them, or rotating them around a colour space).
Anyone have any suggestions - I could rewrite the colour.py logic at script-level (either through a template sensor or directly in a script with some helpers to capture the return value) - but that feels like a waste of time when it’s all sitting there inside HA
or have I just reached the point where I need to get out the python scripts and go play inside HA somehow?