Skip to content
Thomas T. Jarløv edited this page Jan 9, 2019 · 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 a 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 with a 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. #/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, insert 10000 in the "Value data".

The following sounds are available:

Alarms:

  • 0 - Police car 1
  • 1 - Police car 2
  • 2 - Accident
  • 3 - Countdown
  • 4 - Ghost
  • 5 - Sniper rifle
  • 6 - Battle
  • 7 - Air raid
  • 8 - Bark

Doorbells

  • 10 - Doorbell
  • 11 - Knock at a door
  • 12 - Amuse
  • 13 - Alarm clock

Alarm clock

  • 20 - MiMix
  • 21 - Enthusiastic
  • 22 - GuitarClassic
  • 23 - IceWorldPiano
  • 24 - LeisureTime
  • 25 - ChildHood
  • 26 - MorningStream
  • 27 - MusicBox
  • 28 - Orange
  • 29 - Thinker

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