Xiaomi smart home is more correct than home assistant, but it can be even more correct



In previous episodes, I:



  1. I bought devices from Xiaomi for a smart home and, using a soldering iron, made them work in a fun manner - without native servers through the home assistant ( link to the post )
  2. Wrapped the web interface from the home assistant into electron ( link to the post ) with support for notifications, menus, tochbar, etc. (code here)
  3. miio ( ) xiaomi_miio.


, . "" IoT lisp-, . .





Xiaomi:



  • udp
  • ,
  • ,


Home Assistant:



  • ,
  • , Home Assistant
  • Single Point of Failure


home assistant ā€” . ~1000, Home Assistant Raspberry PI ~4000, Home Assistant - . .



, CPU, , " ā€” , ā€” " . Home Assistant.



xiaomi , - , json-based dsl ( ).



"" , . zigbee/ble esp32/nrf51 , ā€¦



.

Xiaomi CO2, , home assistant , , ā€¦.



, , , , , arduino-ide ( -), , , , "" .





Laboratory, 4 weeks old



Proof of concept:



  1. CO2 ā€” 1
  2. ā€” 1
  3. ā€” 2
  4. home assistant ā€” 1
  5. cli ā€” 1
  6. ,




home-assistant Xiaomi "chuangmi.plug.v3 1.3.0_92 ESP8266 detected". , ESP8266 ā€” (~100/) , . Wi-Fi, I2C/SPI/UART/GPIO. ESP8266 Xtensa 80/160Mhz 32- 112 Tensilica ( - , tensilica 2013, esp8266 2014), 1 , .



. ESP8266 . esp201 ā€” , 2.54mm. arduino ā€¦

ā€¦

ESP8266. Xtensa Wi-Fi ā€” , - . nrf51 (~150/). , . .



CO2



aliexpress CO2 ( ). CCS811 ( ). (~500/) , CO2 TVOC , , 60, CCS811 .





LED 8x8 max7219 (~100/). ...





hlk-pm03 (~200/). 4- ; 220v AC, 3.3v DC esp8266.



, . . ( - ā€” ).





:



  • SensorPack ā€” CCS811 ESP201 I2C ( , )
  • Pixel ā€” LED 8x8, max7219 ESP201 SPI


SensorPack





Pixel :





:



  • USB/UART
  • UART "Hello world!"
  • Wi-Fi
  • CCS811 UART
  • / led


20-50 . .



, :



  • /
  • /
  • DSL /




udp , Xiaomi wi-fi , . ā€” udp , ip/ ā€” udp . ā€” . , ā€” xiaomi , ( ), , / "Faster! Harder! Scooter!" " ā€” !".



python.

python , .





Xiaomi-miio ( ).



, aes128-cbc :



  • 128 ā€” Initialization Vector (IV) aes128
  • ā€” , aes128


, IV python arduino api.

python



IV, , replay attack. , xiaomi replay attack, :) , IV IV , . ...



?



, , python-, , . , -. ? FLOPS , , , . , ?! , led , n ā€” .



JS . ESP8266 JS, . Lua, NodeMCU ESP8266. , lua .



lua ā€¦



, :



  1. 1 esp201 lua
  2. NodeMCU lua , . , , ā€¦

    lua , .


uLisp



" ?ā€ ā€” , lisp. , , ---- lisp esp8266, uLisp. c ā€” @technoblogy :



  1. udp
  2. ulisp
  3. s-expression
  4. ip/
  5. api ulisp CCS811 Max7219


Lua , ulisp arduino ulisp . ulisp , , C++. , lisp arduino.



:

192.168.2.99 ā€” IP SensorBoard

192.168.2.174 ā€” IP Pixel



:



python tools/client.py --ip 192.168.2.99 --message '(+ 1 2)' --key YOUR_AES128_HEX_KEY
>> (+ 1 2)
<< 3


discovery. , ulisp.



python tools/client.py --ip 192.168.2.99 --message '(discovery)' --key YOUR_AES128_HEX_KEY
>> (discovery)
<< ("light-read" "co2-read" "tvoc-read" "humidity-read" "temperature-read")


CCS811



python tools/client.py --ip 192.168.2.99 --message '(list (co2-read) (tvoc-read))' --key YOUR_AES128_HEX_KEY
>> (list (co2-read) (tvoc-read))
<< (840 67)


REPL,



python tools/client.py --ip 192.168.2.174 --message '(discovery)' --key YOUR_AES128_HEX_KEY
>> (discovery)
<< ("show" "request")


show ā€” led

request ā€” , , ,



#         led   30   
(defun show_sensor (x)
  (show
    (format nil "CO2=~a TVOC=~a"
      (first x)
      (second x))
    30000))

#   33 ,         show_sensor
(periodic 33000 
  (quote
    (request 
      "192.168.2.99"
      54321
      (quote (list
        (co2-read)
        (tvoc-read)))
      'show_sensor)))


Pixel



$ python tools/client.py --ip 192.168.2.174 --mfile ulisp_scripts/red.ulisp --key YOUR_AES128_HEX_KEY


Pixel SensorPack





lisp . Raspberry PI ā€” . , - Home Assistant lisp . SPoF, Home Assistant.



Home Assistant ,

PoC , ,



SensorPack USB Wi-Fi





, , , dsl, lisp . , s-expression ( json, , lisp ā€” s-expression).



I'll go to sculpt more other devices on the same protocol, next in line are ESP32 and NRF51 ...

And at the same time I will finish the firmware to a more grocery state, if you are suddenly interested, join!



PS All attacks on Home Assistant are made with great love, Iā€™m even a bit of a committer there.




All Articles