Small smart home (sonoff/xiaomi)

Continuing the discussion from DIY: Raspberry Pi UPS/Automatic safe power ON/OFF:

This was the first part of the project, I would go on the same topic if it is not a problem ...
It's about a small project of a smart home.

For now, the hardware is as follows:

  • several Sonoff T1 (single and double channels) with Tasmota firmware
    sonoff-t1-switch

  • Xiaomi Gateway (DGNWG02LM); 1 pcs

gateway_DGNWG02LM

  • AQARA temperature / humidity / pressure sensor; 2 pcs

temperature_and_humidity_sensor_WSDCGQ11LM

  • AQARA motion sensor; 2 pcs
    motion_sensor_RTCGQ11LM

  • AQARA door / window sensor; 1 pcs

door_and_window_sensor_MCCGQ11LM

  • AQARA water leak sensor; 2 pcs

water_leak_sensor_SJCGQ11LM

The gateway should be enabled for developer mode (through the application on the smartphone, set region to Mainland China).
The problem may be if port 9898 is not open, excellent instructions are on:
https://community.openhab.org/t/solved-openhab2-xiaomi-mi-gateway-does-not-respond/52963/171.

In Node-RED I used "A Bridge between the Xiaomi Mi Smart Home Gateway and the Mqtt Broker" .
Works perfectly!

MQTT Broker is locally installed on Raspberry Pi.

The flow of informations for sensors is:
MQTT -> function -> ui_gauge / ui_text / ui_template

For example:
for temp / pressure / humidity informations are:

  • temperature value (ui_gauge)
  • pressure / humidity (text)
  • battery level (text)
  • battery icon (ui_template; red = battery level is bellow 2.7V, cyan = battery level is above 2.7V)

Similar is to all other sensors (except that there are no gauge and different icons).

All sensors except temp / pressure / humidity (after the start of the Node-RED, a one-time trigger request list of registered sensors from the gateway) have the following statuses:

  • if sensor does not respond => text "Error" in red will be displayed instead of the icon,
  • if the sensor responds => text "Online" in yellow will be displayed instead of the icon,
  • if the sensor activates manually (push butoon on the sensor) => text "Ready" in green will be displayed instead of the icon.
    Further sensors show icons with their status.

Night light is a LED on the gateway, this option can be activated or not through the switch in the desired time interval (schedex / gate).
LED light is triggered by a motion sensor (light ON time is fixed:trigger = 2min).

So much for now, with the image of course.
Regards!

4 Likes