MQTT agent for Xiaomi Lumi gateway

Interaction

Default devices

Action Topic Payload Expected values
Read light state lumi/<device_id>/light {"state": "ON", "brightness": 255, "color": {"r": 255, "g": 0, "b": 0},"effect": "fade", "duration":1}
Switch light lumi/<device_id>/light/set ON OFF TOGGLE or {"state": "ON"}
Set light color lumi/<device_id>/light/set {"color": {"r": 255, "g": 0, "b": 0}}
Set light brightness lumi/<device_id>/light/set {"brightness": 255}
Set light effect lumi/<device_id>/light/set {"effect": "fade", "duration": 2}
Set light lumi/<device_id>/light/set {"state": "ON", "brightness": 255, "color": {"r": 255, "g": 0, "b": 0},"effect": "fade", "duration":1}
Read illuminance lumi/<device_id>/illuminance 0-1000 lux
Read cpu temperature lumi/<device_id>/cputemp <float> °C
Button lumi/<device_id>/btn current position 0 or 1
Volume lumi/<device_id>/volume current volume 0-100
Set volume lumi/<device_id>/volume/set 0-100
Volume Alert channel lumi/<device_id>/volumealert current volume 0-100
Set volume Alert channel lumi/<device_id>/volumealert/set 0-100
Play music file lumi/<device_id>/sound/set local path to mp3 file or mp3 url
TTS say text lumi/<device_id>/tts/set or lumi/<device_id>/tts/say text or json {"text":"What to say", "cache": 0} or for Yandex.tts {"text":"What to say", "cache": 1, "updatecache": 1, "voice":"alice", "speed": 10, "emotion": "evil"}
TTS yandex set voice lumi/<device_id>/tts/voice/set one from list of yandex voices Default alyss or google
TTS yandex set emotion lumi/<device_id>/tts/emotion/set one from list of emotions Default neutral
TTS yandex set speed lumi/<device_id>/tts/speed/set 1-30 Default 10
BT scan lumi/<device_id>/bt List of bt devices
BLE scan lumi/<device_id>/ble/<BleMAC> List of ble devices
BLE presence (only for "ble_list" from config) lumi/<device_id>/ble/<BleMAC> {'state': 0} or {'state': 1}

The configuration file is a JSON with the following content:

{
    "mqtt_host": "localhost",
    "mqtt_port": 1883,
    "mqtt_user": "",
    "mqtt_password": "",
    "mqtt_retain": true,
    "topic_root": "lumi/{device_id}",
    //"device_id":"001"
    "auto_discovery": true,
    "connect_retries": 10,
    "log_level": 3,
    "readinterval": 1,
    "treshold": 30,
}

Every line is optional. By default, LumiMQTT will use the connection to localhost with the anonymous login.

device_id if not provided will be automatically replaced by a hex number representing a MAC address of the first network interface.

auto_discovery set to false to disable creating autodiscovery topics that are user by Home Assistant to discover entities.

mqtt_retain is option to enable storing last sensor value on the broker

threshold is a threshold to avoid sending data to MQTT on small changes

readinterval value in seconds to send changed data

To use yandex voices for TTS, you need to specify ya_tts_api_key and ya_tts_folder_id from the Yandex cloud console. ya_tts_voice select voice used by default

cache_tts_path path to save tts cache files cache_tts_all cache all tts phrases, default - save only with json param "cache": 1 cache_tts_make_index on save new cache file add filename and phrase to text file tts-index.txt

led_effect one of none fade wheel transition led_duration number of seconds

disable: array, with some values bt ble illuminance or cputemp to disable

ble_list json array with list of ble devices for check presence, MAC format DD-DD-DD-DD-DD-DD ble_timeout timeout after which the absence is announced

OpenLumi OpenWrt installation

opkg update 
opkg install lumimqttd

To upgrade you can just run

opkg update & opkg install lumimqttd