Posts

Showing posts from January, 2019

how to connect xiomi temperature and humidity sensor to openhab without a gateway

I've a xiomi temperature and humidity sensor with bluetooth. I'm Using openhab and MQTT so it's easy to connect: 1) Create this script (xiomi.sh) : Replace BT with your sensor's mac address. You can find it with:   sudo hcitool lescan (look for  MJ_HT_V1) Change the IP address (192.168.1.100) to your MQQT server address. #!/bin/bash for pid in $( pidof -x xiomi.sh ); do     if [ $pid != $$ ]; then         echo "[$(date)] : xiomi.sh : Process is already running with PID $pid"         exit 1     fi done bt = "4C:65:A8:DC:AD:CF" sensor = "sensor" RET = 1 until [ ${RET} -eq 0 ]; do     data =$( /usr/bin/timeout 20 /usr/bin/gatttool -b $bt --char-write-req --handle = 0x10 -n 0100 --listen | grep "Notification handle" -m 2 )     RET = $?     sleep 5 done RET = 1 until [ ${RET} -eq 0 ]; do     battery =$( /usr/bin/gatttool -b $bt --char- rea