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

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?

Use in HomeyScript:

let devices = await Homey.devices.getDevices();

Then you get all the parameters available of all devices, including capabilities like:
[ ‘onoff’,
‘light_mode’ ],

1 Like

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

1 Like