跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
Wiki首页
Domoticz 中文站
Domoticz 论坛
Domoticz Github
随机页面
特殊页面
特殊页面
所有页面
分类
最近更改
Domoticz
搜索
搜索
登录
个人工具
登录
查看“Xiaomi Gateway (Aqara)”的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
←
Xiaomi Gateway (Aqara)
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
小米网关 Xiaomi (Aqara) makes a smart home gateway/hub that has support for a variety of Xiaomi sensors. They can be purchased on AliExpress or other stores at very competitive prices. Protocol is Zigbee and WiFi, and the gateway and Domoticz need to be in the same network/subnet. Multiple gateways are not supported (this decision has been made to simplify development during beta. For now, you can setup a second Domoticz server on a different subnet to run a 2nd Xiaomi Gateway), however the Smart Socket/Plug *may* act as a wireless repeater so you can use these to extend network range. If you experience problems and are connecting your Domoticz server through a LAN cable, try connecting Domoticz through WiFi instead. '''Currently you need the beta version of Domoticz to support the Xiaomi Gateway and devices''' <span style="background: #c5ffc5;padding: 2px;border: 1px solid #e6e6e6;border-radius: 4px;">Note that the gateway needs to be at least version 2 (DGNWG02LM). Radio support on the gateway indicates at least version 2. If you are unsure, please ask your supplier before purchasing</span> [[File:Xiaomi.jpg]] ==Compatible Devices== Compatible Devices: # Human Body Sensor (Motion Sensor) # Wireless Smart Switch # Door/Window Sensor # Temperature and Humidity Sensor # Smart Socket/Plug - Zigbee version (The WiFi version is not supported) # Xiaomi Mi Smart Cube # Wireless Aqara Switch (Dual Button) # Wireless Aqara Switch (Single Button) # Wired Aqara Switch (Dual Button) # Wired Aqara Switch (Single Button) # Xiaomi Gateway LED, Speaker/Alarm, Illumination Sensor # Xiaomi Smoke Detector # Xiaomi Gas Leak Detector Not Compatible: Other Xiaomi devices that do not connect directly to the Xiaomi Gateway, such as the Robotic Vacuum, WiFi Power Sockets, Bluetooth Lights, Air Purifier, Kettle etc. Even though these devices may be available in the Mi Home App, they do not communicate directly with the Gateway and so are out of scope of this Domoticz plugin which is only for devices that connect through the Xiaomi Gateway. That is not to say these other devices will not work with Domoticz, only that the will need a different plugin, or script - check the forums for more information. ==Adding the Xiaomi Gateway to Domoticz== [[For Android:]] You first need to enable local network functions by using the Android Mi Home App https://play.google.com/store/apps/details?id=com.xiaomi.smarthome # Install the App on a Android device # Make sure you set your region to: Mainland China under settings -> Locale - at time of writing this seems to be required. # Mainland China and language can set on English # Select your Gateway in Mi Home # Then the 3 dots at the top right of the screen # Then click on about # '''Tap the version''' (2.23 is the current Android version as of 8 March 2017) number at the bottom of the screen repeatedly # You should see now 2 extra options listed in English (was Chinese in earlier versions)until you did now enable the developer mode. [ if not try all steps again!] # Choose the '''first''' new option # Then tap the first toggle switch to enable LAN functions. Note down the password (29p9i40jeypwck38 in the screenshot). Make sure you hit the OK button (to the right of the cancel button) to save your changes. # If you change here something, you lose your password! [ this password you need in Domoticz ] [[File:Mihome lan.png]] Now choose the second new menu option, and note down the IP address after "localIp".<br> Make the IP static in your router! [[For iOS:]] You first need to enable local network functions by using the iOS Mi Home App [https://itunes.apple.com/fr/app/%E7%B1%B3%E5%AE%B6-%E7%B2%BE%E5%93%81%E5%95%86%E5%9F%8E-%E6%99%BA%E8%83%BD%E7%94%9F%E6%B4%BB/id957323480?mt=8 iosApp Mi] # Install the App on a iOS device # Make sure you set your region to: Mainland China under settings -> Locale - required for the moment. # Mainland China and language can set on English # Select your Gateway in Mi Home # Then the 3 dots at the top right of the screen # Then click on about # '''Tap under Tutorial menu'''(on the blank part) repeatedly # You should see now 3 extra options listed in Chinese until you did now enable the developer mode. [ if not try all steps again!] # Choose the '''second''' new option # Then tap the first toggle switch to enable LAN functions. Note down the password (29p9i40jeypwck38 in the screenshot). Make sure you hit the OK button (to the right of the cancel button) to save your changes. # If you change here something, you lose your password! [ this password you need in Domoticz ] [[File:Mihome lan.png]] Now choose the '''third''' new menu option, and note down the IP address after "localIp".<br> Make the IP static in your router! Then in Domoticz go to Setup -> Hardware, and choose the Xiaomi Gateway Type. Enter the following: # Name: "Xiaomi Gateway" or anything you want to name it # Remote Address: the IP address of your gateway # Port: Use 9898 <span style="background: #c5ffc5;padding: 2px;border: 1px solid #e6e6e6;border-radius: 4px;">Note that you cannot have another service on your system already using port 9898</span> # Password: The password of your gateway <span style="background: #c5ffc5;padding: 2px;border: 1px solid #e6e6e6;border-radius: 4px;">Note that you may need to clear your browser cache if you can't see the Xiaomi Gateway option and/or all the fields</span> [[File:Xiaomi_03.PNG]] # Then click the Add button. # set in Domotic new hardware and devices active # Navigate to Setup -> Devices, and you should now see detected devices listed. <br> You should learn the new Xiaomi devices [ sensors you have ] first on the gateway with the Xiaomi app. When they are learned in the gateway, you will see the devices under new devices in Domoticz. ==Playing Gateway Sound== Since FW 1.4.1_145.0141 we are able to play sounds stored on the Gateway (Already stored and personalised ones) for using them Domoticz creates 5 Switches : # '''Xiaomi Gateway Alarm Ringtone :''' Off/Police siren 1/Police siren 2/Accident tone/Missle countdown/Ghost/Sniper/War/Air Strike/Barking dogs # '''Xiaomi Gateway Alarm Clock :''' Off/MiMix/Enthusiastic/GuitarClassic/IceWorldPiano/LeisureTime/Childhood/MorningStreamlet/MusicBox/Orange/Thinker # '''Xiaomi Gateway Doorbell :''' Off/Doorbell ring tone/Knock on door/Hilarious/Alarm clock # '''Xiaomi Gateway MP3 :''' Who allow to play personnalise sound that you store on the gateway using MiHome App, see below for more information # '''Xiaomi Gateway Volume :''' Who allow to set Gateway Volume, each time this slider is trigger gateway will play last sound set from Domoticz [[File:gatewaysound.png]] Each Sound can be triggered on Scene/Group/Lua/Blocky and Json Call The following blockly example will show you how to use sounds. This works identical to selector switches. First check what percentage corresponds to your sound by clicking on the 'edit' button of the sound device, for example the doorbell : [[File:Doorbelllevels.PNG]] You can use this value in the Blockly script: [[File:Doorbell.png]] ===About Xiaomi Gateway MP3 === This switch allows you to play sound that you have stored on the gateway using the MiHome App. Each sound has a record number which starts with 100xx: 10000 : Is always stop 10001 : First personalise sound 10002 : Second personalise sound etc etc.. '''When Domoticz creates this Switch, it creates a User Variable : XiaomiMP3 with 10001 as a value :''' remember what is 10001 ? first sound recorded on the gateway ! Change it for 10002, click on Xiaomi Gateway MP3 switch and it will play sound 10002 which is your second personalised sound. ''IMPORTANT : If you record a sound as 10001 and erase it after, 10001 value is no longer usable, each new sound value number growup.'' Actually, we don't know what is the limit, as on file size and on 100xx value ====Easy Way to use personalise sound==== To be more easy to use, we "offer" you a simple tweak who allow you to play 99 personalise sound. First create a dummy Selector, and call it Mid Value, edit this brand new dummy and set it as a Dimmer. [[File:midvalue.png]] Then Create a Device Lua Script who will react to this Dummy Slider and update XiaomiMP3 user variable <syntaxhighlight lang="lua"> --script_device_Xiaomimp3.lua --as each sound is recorded as 100+xx value the slider will update user variable to 10000+dimmer value and play sound commandArray = {} if devicechanged['Mid Value'] then DomValue = otherdevices_svalues['Mid Value']; NumericValue = tonumber(DomValue) Calcvalue = (NumericValue + 10000) commandArray['Variable:XiaomiMP3']=''..Calcvalue..'' print('Xiaomi Gateway will play sound stored on bank '..Calcvalue) commandArray['Xiaomi Gateway MP3']='On' end return commandArray </syntaxhighlight> On the dimmer pic : value is 3 that mean that Variable:XiaomiMP3 is set to 10003, gateway will play the 3rd sound I store on the gateway. With this script each time you change value on the dimmer Gateway will automaticaly play sound, not easy to to on point and clik but really usefull on Scene/Group/Lua/Blocky and Json Call, have a try to record fonction from MiHome app, that an easy way to made some vocal notification with your favorite voice '''Great job Corbin & Deennoo !!''' ==lua scripts example== Using the Xiaomi round Switch: <syntaxhighlight lang="lua"> commandArray = {} -- Commande Selector Switch if (devicechanged['Xiaomi Switch Micro-onde'] == 'Click') then commandArray[1]={['Xiaomi Smart Plug']='On'} commandArray[2]={['Xiaomi Smart Plug']='Off AFTER 10'} end if (devicechanged['Xiaomi Switch Micro-onde'] == 'Double Click') then commandArray[1]={['Xiaomi Smart Plug']='On'} commandArray[2]={['Xiaomi Smart Plug']='Off AFTER 30'} end if (devicechanged['Xiaomi Switch Micro-onde'] == 'Long Click' ) then commandArray['Xiaomi Smart Plug']='On FOR 2' end return commandArray </syntaxhighlight> Xiaomi Motion Sensor to turn on Yeelights at night: <syntaxhighlight lang="lua"> commandArray = {} local minutesnow = os.date("%H") * 60 + os.date("%M") local sunrise = timeofday['SunriseInMinutes'] local sunset = timeofday['SunsetInMinutes'] local nighttime = false if (minutesnow < (sunrise + 25)) or (minutesnow > (sunset - 25)) then nighttime = true end motionLights = {} table.insert(motionLights, {sensorName="Xiaomi Kitchen", lightName="YeeLight Kitchen"}) table.insert(motionLights, {sensorName="Xiaomi Bedroom", lightName="YeeLight Bedroom"}) table.insert(motionLights, {sensorName="Xiaomi Toilet", lightName="YeeLight Toilet"}) for deviceName,deviceValue in pairs(devicechanged) do if nighttime == true then for i, light in ipairs(motionLights) do if (deviceName==light["sensorName"]) then commandArray[light["lightName"]] = deviceValue end end else --need to make sure light turns off when outside of 'nighttime' if deviceValue == "Off" then for i, light in ipairs(motionLights) do if (deviceName==light["sensorName"]) then commandArray[light["lightName"]] = "Off" end end end end end return commandArray </syntaxhighlight> ==Blocky examples== Using the Xiaomi round Switch: [[File:Blocky xiaomi switch.PNG]] ==Troubleshooting== {| class="wikitable" |- ! scope="col"| Problem ! scope="col"| Solution |- | After adding the gateway, no devices are found in Domoticz OR devices do not update state | Solution: You need to ensure the system Domoticz is running on can receive UDP Multicast packets. On Linux, this can be done with '''iptables -P OUTPUT ACCEPT''' '''iptables -I INPUT -p udp -j ACCEPT''' |- | After adding the gateway, no devices are found in Domoticz OR devices do not update state | Make sure the WiFi where your Xiaomi Gateway is connected is on the same subnet as your Domoticz server. Also have your Domoticz server connected directly to the same WiFi network, rather than a LAN cable (try disconnecting the LAN cable as well) |- | Unable to control devices (Smart Plug/Gateway Light/Alarm) | Enter the correct IP address for your gateway. Be aware that if you restart your Xiaomi Gateway, it may get a new IP address and this will need to be updated in Domoticz. Note, devices will still be found if you have an incorrect IP address or password entered. |- | Error: XiaomiGateway: unable to write command - Invalid Key | Enter the correct password for your gateway. Double check it is exact, with no extra spaces. |- | On Raspberry communication is working after setup into Hardware page but not anymore after reboot/restart | Check that the option <Wait for Network at Boot> is enabled ( [https://www.domoticz.com/forum/viewtopic.php?f=17&t=11520&sid=f4ca6e05fca2c07677114bb3a2270d43&start=1460#p137200 check here for details and screenshots] ) |} You can enable the raw gateway messages to appear in the Domoticz log by creating a user variable 'XiaomiMessage' of type Integer and value 1. (Setup -> More Options -> User Variables). Then restart the Gateway hardware in Domoticz.
返回
Xiaomi Gateway (Aqara)
。
开关有限宽度模式