Page 1 of 1

Aqara/ Xiaomi Cube turotial

Posted: Friday 22 November 2019 15:41
by Nephylim
Hi,
I just setup zigbee2mqtt and it seems to work fine.

The only device that I cannot get to work is the xiaomi cube. It adds a couple of devices but I am not really sure what to do with them.
Is there a tutorial for setting up the cube in domoticz?

I added a shot of the created devices to my post.

Re: Aqara/ Xiaomi Cube turotial

Posted: Saturday 14 November 2020 20:19
by henkiev
Hi nephulim,

Just was wondering about that one.
In above picture you can push the green arrows to add the device you want i added the device that gives the switch not using batteries for now.

then i renamed my cube to CUBE1
then i added an ikea light and some other devices, but below the device to control is : zig-stalamp- ikea-e27

then i went to configuration settings and clicked on events, then i create a lua event.. with below. (devicetype)

HOpe this helps, cheers.

Code: Select all

commandArray = {}

print ("*****************   luacube2222    *******************");
if otherdevices['CUBE1'] == 'Rotate Left' then
 print('Lichtsterkte Naar Beneden')
 print(otherdevices_svalues['zig-stalamp- ikea-e27'])
 dimTo = (otherdevices_svalues['zig-stalamp- ikea-e27']-10)
 print(' nieuw:' .. dimTo .. ' ')
 commandArray['zig-stalamp- ikea-e27'] = 'Set Level:'..dimTo..' '
 commandArray['CUBE1'] = 'Off'
end

if otherdevices['CUBE1'] == 'Rotate Right' then
 print('Lichtsterkte Naar Boven')
 print(otherdevices_svalues['zig-stalamp- ikea-e27'])
dimTo = (otherdevices_svalues['zig-stalamp- ikea-e27']+10)
 print(' nieuw:' .. dimTo .. ' ')
 commandArray['zig-stalamp- ikea-e27'] = 'Set Level:'..dimTo..' '
 commandArray['CUBE1'] = 'Off'
end
return commandArray

Re: Aqara/ Xiaomi Cube turotial

Posted: Saturday 14 November 2020 20:21
by henkiev
Also sharing some other lua script for the other options.
I created for what I found on the internet . i do not know the source but nothing worked for me, and below does:

Hope this helps some people.

Code: Select all

--lua device
--maak groep Woonkamer Lampen en maak groep CUBE1 OFF en zet daarin je cube1 op niveau 0%
--maak de scene heu10 , hue60 , hue95 en zet daarin je apparaat heu lamp op het niveau

commandArray = {}
print("*****************   luacube    *******************")

if  otherdevices['CUBE1']=='Flip 90' then
   commandArray['Group:Woonkamer Lampen'] = 'On'
   commandArray['Group:CUBE1 OFF'] = 'Off' 
                     print ("0 CUBE1 Flip 90 zet lampen Aan en CUBE1 uit na 30 sec ");  
   return commandArray
end

if  otherdevices['CUBE1']=='Shake' then
   commandArray['Group:Woonkamer Lampen'] = 'Off'
   commandArray['Group:CUBE1 OFF'] = 'Off'
                     print ("1 CUBE1 SHAKE zet lampen uit en CUBE1 uit na 30 sec ");
    return commandArray 
end

if  otherdevices['CUBE1']=='Tap' then
   commandArray['Group:buitenverlichting'] = 'On'
   commandArray['Group:CUBE1 OFF'] = 'Off' 
                     print ("2 CUBE1 Tap zet buitenverlichting lampen Aan en CUBE1 uit na 30 sec ");
    return commandArray 
end

--if  otherdevices['CUBE1']=='Rotate Right' 
--    and otherdevices['zig-stalamp- ikea-e27']=='On' then
--   commandArray['Scene:kamer80'] = 'On'
--   commandArray['Group:CUBE1 OFF'] = 'Off' 
--   print ("3 CUBE1 Rotate Right zet stalamp hoger kamer80 ");
--    return commandArray 
--end

-- if  otherdevices['CUBE1']=='Rotate Left' 
--   and otherdevices['zig-stalamp- ikea-e27']=='On' then 
--   commandArray['Scene:kamer10'] = 'On'
--   commandArray['Group:CUBE1 OFF'] = 'Off' 
--   print ("4 CUBE1 Rotate Left zet stalamp lager kamer10 ");
--    return commandArray 
--end

if  otherdevices['CUBE1']=='Flip 180' 
   and otherdevices['zig-stalamp- ikea-e27']=='On' then
   commandArray['Scene:kamer100'] = 'On'
   commandArray['Group:CUBE1 OFF'] = 'Off' 
   print ("5 CUBE1 flip180 zet stalamp HOOG kamer100 ");
    return commandArray 
end

 if  otherdevices['CUBE1']=='Slide' then
--   commandArray['Group:buitenverlichting'] = 'Off'
   commandArray['Group:CUBE1 OFF'] = 'Off' 
--                     print ("6 CUBE1 uit na 30 sec ");
    return commandArray 
 end
 
  if  otherdevices['CUBE1']=='Fall' then
--   commandArray['Group:buitenverlichting'] = 'Off'
   commandArray['Group:CUBE1 OFF'] = 'Off' 
--                     print ("7  CUBE1 uit na 30 sec ");
    return commandArray 
 end

--let op hue moet al wel aan staan voor deze scenes 3,4,5 
--Flip90 lampen aan
--Tap buitenlampen aan  
--Rotate Right staLamp naar 80 
--Rotate Left Lamp naar 10 
--Flip 180 STA Lamp naar 100
--slide buitenlampen uit
--Shake Shake alle Lampen uit

Re: Aqara/ Xiaomi Cube turotial

Posted: Saturday 14 November 2020 20:24
by henkiev
I always turn the CUBE1 to off again after firing
But could also be handy to not do that.

For the second script i have created a group called CUBE1 when you use that switch it puts the device itself to off.

Hope to find some fun other scripts here for the aqaura cube.