cadavre / miio_gateway

lumi.gateway.mieu01 with custom miio_client integration for HA
54 stars 22 forks source link

hacs_badge

Miio Gateway

This is Miio Gateway EU version implementation based on encyryption-less miio_client developed by @roth-m.

This component includes XiaomiGw class to communicate with Xiaomi devices via UDP port 54321.

What for?

In general it allows (modified) devices like lumi.gateway.mieu01 to be controlled via LAN instead of Xiaomi Cloud.

Once you replace original miio_client with modified one – you won't be able to control gateway via Mi Home app. But... why you would? ;)

Requirements

Based on lumi.gateway.mieu01

For mentioned gateway you need to gain access to SSH and add another miio_client binary to device.

  1. To obtain SSH access follow this tutorial.
  2. Add new binary following this readme.

Notice! You need to keep old miio_client because it's required for initialization of connection.

Warning! Launching modified miio_client will disable Xiaomi cloud access so you won't be able to control the gateway from Mi Home app!

What is supported

Installation of HA component

  1. Clone this repo as miio_gateway dir into $HA_CONFIG_DIR/custom_components/:
    $ cd custom_components
    $ git clone git@github.com:cadavre/miio_gateway.git ./miio_gateway
  2. Setup $HA_CONFIG_DIR/configuration.yaml:
miio_gateway:
  host: 192.168.1.2    # IP of your gateway
  port: 54321          # port running miio_client, defaults to 54321
  sensors:             # sensors that will be available in HA (optional)
    - sid: lumi.abcd
      class: motion                           # motion sensor
      friendly_name: My garage motion sensor  # display name (optional)
    - sid: lumi.0123
      class: door                             # door sensor
      restore: true                           # will restore sensor state after HA reboot
    - sid: lumi.ab01
      class: button                           # button
    - sid: lumi.smk1
      class: smoke                            # smoke sensor

Zibgee devices

Pairing

You can pair new devices without entering Mi Home app by using HA service, just call:

miio_gateway.join_zigbee

service to enter pairing mode. No need to kep original miio_client up for 10mins after gateway reboot!

Adding sensor to HA

Once you've paired new device you'll be able to see "unregistered" sensor in your HA logs.

Received event from unregistered sensor: lumi.sensor_motion.v2 lumi.abcd - event.motion
                                         ^ model               ^ sid       ^ event that was sent

Use SID to define it in sensors: section of configuration.yaml.

Using Zigbee button

Zigbee buttons are triggering an events for their actions.

Event type: miio_gateway.action

Available event data: event_type

Click type available payloads:

Automation example:

- alias: 'Toggle the light'
  trigger:
    platform: event
    event_type: miio_gateway.action
    event_data:
      event_type: 'click'
      entity_id: 'binary_sensor.lumi_ab01_button'
  action:
    - service: light.toggle
      entity_id: light.my_light

Using vibration sensor

Just like button – vibration sensor sends one of two events:

You can use them just like with buttons. Event type is still event_type: miio_gateway.action.

Alarm finetuning

Since implementation of HASS'es alarm_control_panel into miio_gateway component requires a lot of copy-paste – I abandoned this idea.

Instead you can use coupled_alarms.

Changelog

v.1.6.0

v1.5.0

v1.4.0

v1.3

v1.2

v1.1

Breaking changes (v1.1)

General
Button events

Not supported yet

Not supported but likely to work with: