Skip to content
Thomas T. Jarløv edited this page Aug 7, 2018 · 5 revisions

Devices

Xiaomi IOT devices are supported. The following devices has been thoroughly tested:

Working with Xiaomi

You can interact with the Xiaomi devices in 3 ways:

  1. Read - Asking for their status, e.g. is the door open (door sensor)
  2. Report - Awaiting an action, e.g. when the door opens, it sends a notification (door sensor)
  3. Write - Send a message to the device (only some devices accepted this), e.g. play a sound (gateway)

All you Xiaomi devices are connected to a gateway. It is through this gateway, we are communicating with each of the devices. Each devices is identified by with SID. Before NimHA can use the Xiaomi devices, you need to setup the gateway and the devices with your Xiaomi app.

Write to a device

To write to a device, we need to exchange a encrypted key with the gateway based on a ever-changing token. We are currently using a Python script to generate the encrypted key from the token.

Gateway password

But before we can generate the key, you need to gather you gateway password. Follow this guide Domotics or the bullets below. Remember to write the key down.

  1. Install the Xiaomi app
  2. Set the region to Mainland China under Settings->Locale
  3. You can set the language to English, even though the region is China
  4. Sign in/Make an account
  5. Select your Gateway in the app
  6. Tap the 3 dots in top right corner
  7. Click About
  8. Tap on the version repeatedly until a new menu appear
  9. Click on Wireless communication protocol
  10. Enable the this and write down you password and press Ok

Discover devices

Inside NimHA goto the Xiaomi page.

Press the "Auto discover" button and wait. NimHA will find the connected Xiaomi devices and list them for you. You can change their names used in NimHA.

Sensors

Inside NimHA goto the Xiaomi page.

Only devices that you can either read data from or devices their report status are allowed.

Read

To continuously read a value each time it changes, you have to set the action to read. This will ensure, that the value will be displayed on your dashboard.

When reading a value, the "Value data" needs to be empty.

Report

The report is primary used in conjunction with the alarm. When using the report, you also need to specify the "Value data" and the "Trigger alarm".

For PIR sensors the "Value name" would be status and the "Value data" would bed motion.

For magnet sensors the "Value name" would be status and the "Value data" would bed open or close.

Value name

Examples of possible values for "Value data":

  • Read: PIR sensors will respond with motion
  • Read: Magnet sensors will respond with voltage
  • Read: Magnet sensors will respond with status for the switch
  • Report: PIR sensors will respond with status
  • Report: Magnet sensors will respond with status for the switch

Actions

Inside NimHA goto the Xiaomi page.

Only devices that you can write data to are allowed.

Ringtone (gateway)

Insert ringtone in the "Value name". Insert the ringtone number in "Value data": 8

To adjust the volume, append a comma and the volume number. Using ringtone 8 and volume level 4: 8,4

To create an action to stop the sound (good idea!), insert 10000 in the "Value data".

Color (gateway)

Insert rgb in the "Value name". Insert the preferred color code in "Value data". For a red light insert: 4294914304

To assign a RGB color, you have to use the Android() color format.

You can convert HEX to Android() at this website.

  • Red = 4294914304
  • Green = 4283359807
  • Purple = 4283637131
  • Yellow = 4292211292
  • Blue = 4283327469
  • Off = 0