Mood lamp with IKEA TRÅDFRI

Hi, guys! I own some IKEA TRÅDFRI bulbs and I want to automate them in some way so they act like mood lamps. To be exact I’m looking for some algorithm they will change their colors randomly, but I can’t just use random RGB values because they can turn into white or to the color, that is too similar to previous one. I can write such a code in, for example, C++, but as far as I understand (I’m very new in HASS, by the way), HASS doesn’t support variables in automations or scripts.

Please help me to reach my goal! Thanks in advance!