Suggestions to simplify flows for 'slowly' changing light colour and brightness

(( apologies for the formatting of the post. I’ll try to fix it if it is too messy at first ))

I was wondering if people here have an idea to simplify a number of flows I currently have.


My end-goal is the following:
I want my Philips Hue white ambiance (For those who are not familiar with it: They are white bulbs, varying light from very cold (blueish) to very warm (amberish) and everything in between) to slowly go ‘warmer’ based on the position of the sun.

Suppose the lights are on at mid-day (sun very high/bright), the light is ‘very white’
and if you turn on the lights at midnight (sun very low/not there), the light is ‘very warm’

When the lights are on, and the sun is setting, the light should gradually go warmer but in such a way that I don’t see them suddenly change colour.

Currently used apps:

I currently do this using the following apps:

  • Sun Events by Marcel Timmermans to get the position of the sun
  • Philips Hue Zigbee by Sebastian Johansson to control my Hue bulbs
  • Better Logic by Patrick Sannes to set various variables and slowly change them based on the ‘mathjs’ function

Here are my current flows:

Trigger based on sun event


  • Sun Event is “Begin of sunset”


  • set better logic numeric variable “target_light_temperature” to 0.65
  • set better logic numeric variable “target_light_brightness” to 0.8


  • Sun Event is “Nautical dusk”


  • set better logic numeric variable “target_light_temperature” to 0.7
  • set better logic numeric variable “target_light_brightness” to 0.75

(etc, for a number of Sun Events)

Detect changed target variables

I then 'detect the changed 'target-variables:

  • better logic numeric variable “target_light_temperature” changes


  • Start Flow “Slowly lower light temperature”
  • Start Flow “Slowly raise light temperature”


  • better logic numeric variable “target_light_brightness” changes


  • Start Flow “Slowly lower light brightness”
  • Start Flow “Slowly raise light brightness”

Slowing start changing ‘current’ variables towards ‘target’ variables:

These flows look like (one example):

  • flow is started (Slowly raise light temperature)


  • better logic numeric variable “target_light_temperature” is greater than variable “current_light_temperature”


  • Better logic: set variable “current_light_temperature” to mathjs: “round( current_light_temperature + 0.01 ) * 100 / 100”
  • Start flow “Slowly raise light temperature” after 5 seconds

This effectively loops the flow “Slowly raise light temperature” until variable “current_light_temperature” is equal to “target_light_temperature”, gradually raising it by 0.01 point every 5 seconds
(( the mathjs is required, because sometimes the variables get skewed causing 0.5 + 0.01 to become: 0.50000001 or something, which the hue bulb doesn’t understand ))

‘Current’ variables are changed

Then another flow reacts on the changed variables:

  • variable “current_light_temperature” changes (or)
  • variable “current_light_colour” changes


  • Start flow: “Apply new light settings”

Apply the light settings

Then the flow Apply new light settings:

  • the flow starts


  • Set hue bulb colour to “current_light_temperature”
  • Set hue bulb brightness to “current_light_brightness”

The above is the simplified version of the actual flows:

Additional complexity built in are the following, but probably not relevant to my question:
When the lights are off, and the better logic target_light_* variables are changed by a Sun Event, then they the ‘slow’ part is bypassed and the ‘current_light*’ variables are immediately changed (so not going slowly). The purpose of this is the following:
Suppose the Sun Event starts at 19:00, then it can take a few minutes before the end-goal is reached.
If I turn on the light at 19:01, then the lights go on, directly to their targeted values.
I did this, so that Homey doesn’t have to go through the loops when they are not actually changing the bulb settings

This is it :slight_smile:
If anyone needs any clarification, I’ll try to update this post.


WOW, props to you Lennard, this is really well-thought of :raised_hands:

Thanks :slight_smile:
It took some time to figure it out and to get it to what I wanted as an end result with the limitations of the Homey logic. (if this then that) and also keep it manageable.

Luckely I did it with the previous Web interface of the 1.x series, which was more accessible to this kind of flow combinations.

I hope it inspired you to make your own complex flow combinations to get to your goals.

1 Like

Have you checked out the transitions app by @robertklep?

I’ve previously used that to transition through colours … it might be helpful to what you’re trying to achieve.

Thank you for the suggestion (and sorry for the late reply :slight_smile: )

I did look in to that one. On a most basic level it works nicely. The downside on the app however is, is that it doesn’t accept variable inputs. As in: Suppose the light is currently set to ‘0.6’, there is no way to tell that to the app without hardcoding it.

Ideally it would have accepted start-point is ‘current brightness value’

You should be able to use tokens in the transition values:


I didn’t get that to work last time I tried (Homey 1.x from top of my head) I just gave it a go and now it works for me!

Thanks loads! This can simplify my flows big time! I’ll change my flows soon! :slight_smile: