I’m trying to clean up some janky color detection logic for my Bambu AMS tray sensors in Home Assistant. Each tray exposes a color attribute that looks like an 8-digit hex value. I want to automatically convert that into a readable filament color name (Red, Blue, White, etc.)
Right now, I’m using a Template Entity Row in Lovelace to translate that hex into names using a ton of if/else checks. It does work… but it feels super brute-force, slow, and hard to maintain. Here’s the code for one tray if anyone wants to take a peek:
Is there a smarter way to do this? Maybe some sort of HACS integration or tool I haven't found out about yet?