# Colour therapy room

**URL:** https://community.homey.app/t/colour-therapy-room/14260
**Category:** Flows
**Created:** [June 9, 2019, 6:38pm UTC](https://community.homey.app/t/colour-therapy-room/14260 "2019-06-09T18:38:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![on1dds](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/on1dds/32/9421_2.png) [@on1dds](https://community.homey.app/u/on1dds)
#### Post date: [June 9, 2019, 6:38pm UTC](https://community.homey.app/t/colour-therapy-room/14260/1 "2019-06-09T18:38:40Z")

</div>

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/](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

---

<div class="post-metadata">

### Author: ![Astrapowerrr](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/astrapowerrr/32/78916_2.png) [@Astrapowerrr](https://community.homey.app/u/Astrapowerrr)
#### Post date: [January 1, 2024, 7:13pm UTC](https://community.homey.app/t/colour-therapy-room/14260/2 "2024-01-01T19:13:11Z")

</div>

> [@on1dds](#):
>
> 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/](https://homeyscript.homey.app/))
> 
> **script 1: relax\_init\_colour**
> 
> ```auto
> // 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**
> 
> ```auto
> // 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**
> 
> ```auto
> // 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

hi,

what a perfect idea.  
i have been grinding the forum for days to find something like you invented!

i just copied and tried to get it up and running but nothing happens. can you you give me a hand where its going wrong in my setup?

thanks.
