Xiaomi Cube - shake_air Topic is solved

Moderator: leecollings

Post Reply
DreaMare
Posts: 26
Joined: Friday 03 February 2017 16:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Xiaomi Cube - shake_air

Post by DreaMare »

Hello every one !

With this code (1) in web interface : all work well but I got this error :
2017-02-19 19:24:00.198 Error: EventSystem: in script_device_cube.lua: [string "-- script_device_cube.lua..."]:5: attempt to index global 'devicechanged' (a nil value)

When i put this lua script in /home/pi/domoticz/scripts/lua, the error disappear but the shake_air doesn't work : / (the other change work well)

Thank you !

(1)

Code: Select all

-- script_device_cube.lua

commandArray = {}

if devicechanged['Xiaomi Cube Switch'] == "shake_air" then

    commandArray['Scene Tout éteindre'] = "On"    
    
elseif devicechanged['Xiaomi Cube Switch'] == "flip180" then
    
    commandArray['Scene Catoune on'] = "On"  
    
elseif devicechanged['Xiaomi Cube Switch'] == "tap_twice" then
    
    commandArray['Scene Office on 1426365250000'] = "On"     
    
elseif devicechanged['Xiaomi Cube Switch'] == "flip90" then
    
    commandArray['Scene Cinema on 1438118688000'] = "On"       
    
elseif devicechanged['Xiaomi Cube Switch'] == "move" then
    
    commandArray['Scene Saenger Sky on 1403011832000'] = "On"           

elseif devicechanged['Xiaomi Cube Switch'] == "clock_wise" then
    
    commandArray['Scene 12th Man on 1403013718000'] = "On"       

elseif devicechanged['Xiaomi Cube Switch'] == "anti_clock_wise" then
    
     commandArray['Scene Détente'] = "On"   

end


return commandArray
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: Xiaomi Cube - shake_air

Post by bertbigb »

First be sure that you store this script as a device script and let start to do that in the web interface since that is the most easy way

--> devicechanged commands only works in device scripts

Then the script complaints about Line 5 --> if devicechanged['Xiaomi Cube Switch'] == "shake_air" then

are you sure that you have a device 'Xiaomi Cube Scene' defined in domoticz?
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
DreaMare
Posts: 26
Joined: Friday 03 February 2017 16:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Xiaomi Cube - shake_air

Post by DreaMare »

bertbigb wrote:First be sure that you store this script as a device script and let start to do that in the web interface since that is the most easy way

--> devicechanged commands only works in device scripts
=> the name of file is : script_device_cube2.lua so i guess it's ok ?

bertbigb wrote:are you sure that you have a device 'Xiaomi Cube Scene' defined in domoticz?
I don't have set "Xiaomi Cube Scene", so I have to set one ?

I don't understand why the script on the interface work well, but not the one in folder :"/home/pi/domoticz/scripts/lua" : /
Attachments
xiaomi.png
xiaomi.png (46.81 KiB) Viewed 2450 times
cube (2).png
cube (2).png (136.34 KiB) Viewed 2450 times
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: Xiaomi Cube - shake_air

Post by bertbigb »

DreaMare wrote: => the name of file is : script_device_cube2.lua so i guess it's ok ?
Yes that should be OK

DreaMare wrote: I don't have set "Xiaomi Cube Scene", so I have to set one ?
I don't understand why the script on the interface work well, but not the one in folder :"/home/pi/domoticz/scripts/lua" : /
No I made a mistake by not reading correct (I read Xiaomi Cube Scene instead of Xiaomi Cube Switch) you have defined the Xiaomi Cube Switch so that can't be the case for the error 2017-02-19 19:24:00.198 Error: EventSystem: in script_device_cube.lua: [string "-- script_device_cube.lua..."]:5: attempt to index global 'devicechanged' (a nil value)

Do you still got this error?
I don't understand why the script on the interface work well, but not the one in folder :"/home/pi/domoticz/scripts/lua" : /
That I do not understand either, I myself always use the webinterface. Since I work on a Synology the path is different as yours on a pi also. Hope someone else can help you with that.

I'm waiting for my own Cube Switch and then will try it myself also.
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
DreaMare
Posts: 26
Joined: Friday 03 February 2017 16:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Xiaomi Cube - shake_air

Post by DreaMare »

thank you anyway : )
I try out somethings but still got error.
And the script is a bit laggy and shake_air doesn't work :(
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Xiaomi Cube - shake_air

Post by deennoo »

As this is a device script, you have to set your script to device and not to all, just under LUA string
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
DreaMare
Posts: 26
Joined: Friday 03 February 2017 16:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Xiaomi Cube - shake_air

Post by DreaMare »

deennoo wrote:As this is a device script, you have to set your script to device and not to all, just under LUA string
How ?
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: Xiaomi Cube - shake_air

Post by bertbigb »

Event Settings.png
Event Settings.png (11.01 KiB) Viewed 2372 times
Here you tell what type of script it is, like Dennoo writes not All but Device

I hope this pictures helps you to get it fixed
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
DreaMare
Posts: 26
Joined: Friday 03 February 2017 16:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Xiaomi Cube - shake_air

Post by DreaMare »

thank's a lot ; )
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest