Hello all,
I’d like to share how I worked out an idea I had. We have recently installed a new relax room in our house with a sauna, bed, relaxing paintings and such. I thought it would be nice to also add colour therapy to the room using my Homey. To make this, I bought some RGB lamps (Ikea Tradfri and Philips Hue) and wrote some flows and HomeyScripts to make them continuously change color to create some kind of colour therapy. It works on all RGB lamps in a given room at the same time.
You can tweak the speed by changing the TherapyCounter
(seconds before next colour is picked) and the increments on the current_hue
variable (stepsize between two consecutive hue values/colours).
Therapy evidently starts with running the Therapy Start
flow and stops with running the Therapy Stop
flow. Here’s how I did it:
HomeyScript App
Create these three scripts in the HomeyScript website (https://homeyscript.homey.app/)
script 1: relax_init_colour
// initialize all RGB lamps in zone 'Relax room' to red
let devices = await Homey.devices.getDevices();
_.forEach(devices, device => {
if(!device.capabilities.includes("light_hue")) return;
if(device.zoneName != 'Relax room') return;
device.setCapabilityValue('onoff', false);
device.setCapabilityValue('dim', 1);
device.setCapabilityValue('light_hue', 0);
device.setCapabilityValue('light_saturation', 1);
device.setCapabilityValue('light_temperature', 0);
device.setCapabilityValue('light_mode', 'color');
});
return true;
script 2: relax_set_colour
// set all RGB lamps in zone 'Relax room' to the hue value
// received in a parameter
if (args[0] === '') {
return false;
} else {
let hue = parseFloat(args[0],10) % 1;
console.log(hue);
let devices = await Homey.devices.getDevices();
_.forEach(devices, device => {
if(!device.capabilities.includes("light_hue")) return;
if(device.zoneName != 'Relax room') return;
device.setCapabilityValue('light_hue', hue);
device.setCapabilityValue('light_saturation', 1);
device.setCapabilityValue('light_temperature', 1);
device.setCapabilityValue('available', true);
device.setCapabilityValue('ready', true);
});
return true;
}
script 3: relax_set_white
// Set all RGB lamps to to white
let devices = await Homey.devices.getDevices();
_.forEach(devices, device => {
if(!device.capabilities.includes("light_hue")) return;
if(device.zoneName != 'Relax room') return;
device.setCapabilityValue('onoff', false);
device.setCapabilityValue('dim', 1);
//device.setCapabilityValue('light_hue', 0);
device.setCapabilityValue('light_saturation', 1);
device.setCapabilityValue('light_temperature', .3);
device.setCapabilityValue('light_mode', 'temperature');
});
return true;
Better Logic App
Create two better logic variables:
-
boolean
in_therapy
=false
-
number
current_hue
=0
CountDown App
Create a timer:
-
Timer
TherapyCounter
Flows
Flow: Therapy Start
When
This Flow is started
And
-
Then
-
BetterLogic Set boolean variable
in_therapy
=true
-
BetterLogic Set number variable
current_hue
=0
-
HomeyScript Run a script
relax_init_colour
-
HomeyScript Run a script with an argument
–relax_set_colour
[current_hue
] -
Flow Start
Therapy - Delay
Flow: Therapy Stop
When
: This Flow is started
And
-
Then
-
BetterLogic Set boolean variable
in_therapy
=false
-
HomeyScript Run a script
relax_set_white
Flow: Therapy Delay
When
This Flow is started
And
BetterLogic is true in_therapy
Then
CountDown Start countdown timer TherapieCounter
= 5
Flow: Next Colour
When
: CountDown Timer reaches zero (0): TherapyCounter
And
BetterLogic is true in_therapy
Then
:
-
BetterLogic: Increment number variable
current_hue
=0.1
-
HomeyScript: Run a script with an argument
–relax_set_colour
[current_hue
] -
Flow: Start
Therapy - Delay
Have fun with it.
Kind regards,
Joachim