MI HOME: Scenario execution via local network or via Xiaomi cloud server
5 min readSometimes Xiaomi smart home scenaries executing rapidly even without Internet connection. But in other cases they running very slow. Why it happens and how to fix it?
Xiaomi Mijia Smart Gateway 3 - Mi Home Hub, ZigBee, WiFi, Bluetooth Compatible
Xiaomi
Xiaomi Mijia Smart Gateway 3 is a smart home hub that supports ZigBee, WiFi, and Bluetooth protocols, allowing you to connect and control all your smart devices through the Mi Home app.ZNDMWG03LM
When Xiaomi smart home scenario will execute via local network, and when via cloud server?
You may have noticed that some scenarios in your smart home always execute quickly and clearly, while others - with a second or more delay and sometimes do not executing at all. What's the matter? What does it depend on? Let's start edit one of the scenarios in the Mi Home app, and click on the ellipsis in the upper right corner (for scenarios 1.0):
We will see a fixed setting: Running mode: LAN or Running mode: Cloud:
The script above is executed in "LAN" mode. That means, what if the motion sensor detects movement, it will send a signal to the gateway
(Mi Home GatewayMi Home Gateway),
and the gateway via Bluetooth will turn on light bulb number 6 in the hallway. Such scenario will work almost instantly. And nothing will change if the gateway loose Internet connection - the scenario will work in the same way.
For new style scenarios you can find this information by click on "More" section in the bottom of the scenario:
In the screen which will open, you'l see the current mode of the scenario: "Running mode: LAN"
How would this same scenario work in Cloud mode?
- The motion sensor will send a signal to the gateway.
- The gateway through the Internet will send the command to the Xiaomi cloud server.
- The Xiaomi server (in my case, located in China), by the scenario, will give a command to turn on the light bulb and send it to the gateway via the Internet
- The gateway, having received the command, will send it to the light bulb via Bluetooth
Probably you already understand where the execution delay will appear in this case and why such a script will not work if there is no Internet connection
So, you need to switch all scenarios to LAN mode where it possible! Okay, but how to do that? The mode selector is inactive, i.e. the Mi Home app selects when to turn on LAN and when to turn on Cloud. Worse, you can save the script, make sure LAN mode is selected, and after a few days notice that the script "slows down", go to the application, and found what the LAN changed to Cloud. So, how to manage it?
The Mi Home app will always try to select "LAN" mode when possible. In what cases will this not work?
- The scenario involves devices connected to different gateways. For example, a motion sensor has connected to gateway 1, and a lamp connected to gateway 2. In this case, you just need to change the device binding, reset one of them, and add it again, specifying a different gateway (the device settings will be saved).
Sometimes such scenarios still remain in LAN mode, sometimes - not. Zigbee devices are locked to the gateway to which they were originally attached, while Bluetooth Mesh devices can spontaneously "drift" between gateways.
-
The scenario uses a WIFI device. Well, modern Mi Home ecosystem remains working without cloud connections even for WiFi devices, but anyway, The 2.4 GHz WiFi network is usually already overloaded, so it is better to use other wireless protocols. In addition, devices that have a full Internet stack on board are less secure. One day, if you neglect security, you may find that your wifi surveillance camera is trying to guess passwords for some Wordpress site (this is from real cases).
-
A scenario is enabled or disabled from another scene. This is the most insidious case. It is very convenient when, depending on certain conditions, you can disable or enable the execution of another scene. But, after the first such "external control" the script will switch to Cloud mode, even if initially it is saved as LAN.
Try to avoid such cases where it possible, and most of the scenes will operate in LAN mode.
Whenever possible, if you cannot avoid executing the script in "Cloud" mode, try to duplicate the most of it
functionality in an additional scenario that can work in “LAN” mode (for example, so that the lights in the room will turn on
in any case, even if there is currently no connection to the external server, or connection is too slow).
If you are creating very complex scripts for your smart home, then you may think about a gradual transition to alternative Smart Home systems, for example, Home Assistant. Today it can work with almost all devices in the Mi Home ecosystem and many other devices, without the Chinese cloud and completely locally. But setting up such a system will take much more efforts than Mi Home app, for current time it mostly suitable for IT persons.
Comments:
Alex, 2023-03-12:
Thanks. I did not know what smart home can operate in some cases even without internet connection