# Storing tags from Mi-lights and setting Mi-lights from variables

**URL:** <https://community.homey.app/t/storing-tags-from-mi-lights-and-setting-mi-lights-from-variables/14979>\
**Category:** Questions & Help\
**Created:** [June 30, 2019, 11:07am UTC](https://community.homey.app/t/storing-tags-from-mi-lights-and-setting-mi-lights-from-variables/14979 "2019-06-30T11:07:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Satoer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/satoer/32/38113_2.png) [@Satoer](https://community.homey.app/u/Satoer)\
**Post date:** [June 30, 2019, 11:07am UTC](https://community.homey.app/t/storing-tags-from-mi-lights-and-setting-mi-lights-from-variables/14979/1 "2019-06-30T11:07:53Z")

</div>

I’m trying to activate my mi-lights when a (Xiaomi Aqara) motion sensor detect motion and setting them back to the previous setting (brightness, color, white, on, off… whatever) when there is motion inactivity.

The way I tried to accomplish this, is by storing every light parameter to a variable in a flow activated by the motion sensor, and restore the lights based on these variables when a motion inactivity flow gets triggered.

I can retrieve (from the light tags):

-Dim level 0-1  
-Hue 0-1  
-Color temperature

When monitoring these tags I’ve discovered that the hue stays the same even if I activate white light. Also when I turn the lights off, these settings do not change.

The problems when restoring the lights from mi light tags:

- I cannot see if the previous lights where on / off (tags do not change when turning off the lights)
- I cannot see if the previous lights where in white mode or color mode (Hue stays the same when activate white light)
- I cannot see if the previous lights where in disco mode (less important, but there should be a tag)

Some other “problems”:

There is no option to set the hue of the light. I can change the tint from variables 0-360 degrees, so apparently I have to calculate the tint from the hue.

What I need:

Tag: Light tint tag (0-360 degrees)  
Tag: Light mode (0,1,2,4) for: off, white mode, color mode, disco mode  
Tag: Disco mode (which disco mode)  
Tag: Speed (for disco)  
Tag: Dim level (already exists)  
Tag: Color temperature (already exists)

And options to set all these settings. Especially “Set Light mode”

For now, I don’t know a feasible workaround. I could create all my own variables when setting the lights in all the scenes. But applying these settings will be a messy multiple flow nightmare. (for every possibility I need to create a separate flow…)

Has anyone else has worked with a similar situation? Maybe it’s possible to retrieve more tags using homey script?

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [June 30, 2019, 1:40pm UTC](https://community.homey.app/t/storing-tags-from-mi-lights-and-setting-mi-lights-from-variables/14979/2 "2019-06-30T13:40:00Z")

</div>

Use in HomeyScript:

> let devices = await Homey.devices.getDevices();  
> console.log(devices);

Then you get all the parameters available of all devices, including capabilities like:  
capabilities:  
[ ‘onoff’,  
‘dim’,  
‘light\_hue’,  
‘light\_saturation’,  
‘light\_temperature’,  
‘light\_mode’ ],

---

<div class="post-metadata">

**Author:** ![Satoer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/satoer/32/38113_2.png) [@Satoer](https://community.homey.app/u/Satoer)\
**Post date:** [June 30, 2019, 5:20pm UTC](https://community.homey.app/t/storing-tags-from-mi-lights-and-setting-mi-lights-from-variables/14979/3 "2019-06-30T17:20:43Z")

</div>

That’s great… I’m diving into HomeyScript!
