Skip to content
Torte edited this page Feb 18, 2020 · 36 revisions

Required PERL Module

The following Perl modules must be installed:

  • JSON
  • MULTICAST
  • CBC (for AES encryption)
  • Crypt::Cipher::AES (for AES encryption)

root@fhemdev:~# apt-get install libio-socket-multicast-perl

root@fhemdev:~# apt-get install libjson-perl

root@fhemdev:~# apt-get install libcrypt-cbc-perl

root@fhemdev:~# cpan Crypt::Cipher::AES

Set Developermode on the gateway!

Without the developer mode, no communication with the XiaomiSmartHome gateway is possible. You need an android or ios device. You must often click on the APP versionsnumber to activate the hidden menu. Here is how to turn on the developer mode.
Android -> https://louiszl.gitbooks.io/lumi-gateway-local-api/content/device_discover.html
IOS go here -> https://github.com/fooxy/homeassistant-aqara/wiki/Enable-dev-mode
The password shown in the app must set on the FHEM XioamiSmartHome Gatewaydevice! (see additional pictures below)

Used Ports / Firewall

The gateway communicates via UDP ports 9898 and 4321. If you use a firewall, both ports must be opened. Disabling multicastfilters in your firewall is also a good idea.

DEFINE

define <DEINNAMEWIEDUWILLST> XiaomiSmartHome <IP_DES_MI_GATEWAYS>

Update FHEM Modules

devStateIcon

motion: motion:motion_detector@red off:motion_detector@green

magnet: open:fts_door_open@red close:fts_door@green

leak: leak:humidity@red no_leak:humidity@green

motionOffTimer

You can set a motion Off Timer Attribut on the motion sensor device. You can set 1, 5 or 10 seconds after the motion sensors will automatically set to off. Background: The motionsensors does not send off immediately. The Motionsensor send a no_motion after 120, 180, 300, 600, 1200 seconds no motion is detected.

Setting attribut timestamp-on-change-reading and event-on-change-reading

Every sensor will send every hour a heartbeat signal. The reading state will also set to prevent that set the attributs:

timestamp-on-change-reading   state
event-on-change-reading   .*

From now the reading state will only change if the sensor will change e.g. door open or close (magnet sensor) FHEM Set attributs

Password for WRITE (Change GW LED Color, ...)

  • Start Xioami APP About Click About

gateway information Click Gateyway information

Pushbutton Click on the left Pushbutton

Password

Set the password on the GatewayDevice in FHEM FHEM Set password

Using FHEM in a DOCKER Container.

Since the Xiaomi gateway distributes its data in the network via UDP and multicast, it is not possible to operate FHEM in a docker container together with the Xiaomi gateways. The FHEM user "ROAM" Robin has found a way to run FHEM in a docker container. The FHEM Docker Container must be run in HOSTMODE. This is achieved by the parameter --net=host.

For example docker run -d --name fhem --net=host fhem/fhem

FHEM Forum (German)

Thanks to Robin for finding out.