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.
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? ;)
Based on lumi.gateway.mieu01
For mentioned gateway you need to gain access to SSH and add another miio_client binary to device.
- To obtain SSH access follow this tutorial.
- 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!
-
Built-in LED as
light.miio_gatewaycomponent.With brightness and colors.
-
Built-in speaker and sounds library as
media_player.miio_gatewaycomponent.With play, stop, mute, set_volume and play_media with ringtone ID as media ID.
-
Built-in luminescence sensor (yes, there's one) as
sensor.miio_gateway_illuminancecomponent.Sensor shows readings in lumens.
-
Built-in alarm functionality as
alarm_control_panel.miio_gatewaycomponent.Arm, disarm; night/home/away modes supported via alarm volumes: 5/15/70.
-
Child sensors as
binary_sensor.Currently supported are:
- motion sensors,
- door/window sensors,
- leak sensors,
- buttons.
-
Child sensors as
sensor.Currently supported are:
- temperature sensors,
- humidity sensors,
- pressure sensors.
- Clone this repo as
miio_gatewaydir into$HA_CONFIG_DIR/custom_components/:$ cd custom_components $ git clone [email protected]:cadavre/miio_gateway.git ./miio_gateway - 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 # buttonYou 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!
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.
Zigbee buttons are triggering an events for their actions.
Event type: miio_gateway.button_action
Available event data: click_type
Click type available payloads:
clickdouble_clicklong_click_presslong_click_release
Automation example:
- alias: 'Toggle the light'
trigger:
platform: event
event_type: miio_gateway.action
event_data:
event_type: 'single_click'
entity_id: 'binary_sensor.lumi_ab01_button'
action:
- service: light.toggle
entity_id: light.my_lightJust like button – vibration sensor sends one of two events:
vibrationon vibrationfree_fallon free-falltilton tilt by an anglebed_activityon... bed activity? :D
You can use them just like with buttons. Event type is still event_type: miio_gateway.action.
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.
- Added
restoreparam to sensor mapping. Defaults tofalse, will restore pre-HA restart state if set totrue.
- UDP socket gateway connection rebuilt.
- Supports re-connections now.
- Gateway after-unavailable state is now refreshed.
- Fixed wrong logging params that caused gateway to freeze, thanks @quarcko !
- Changed entity_id and name generation methods.
- Added support for temp/humid/pressure sensors.
- Added support for vibration sensor.
- Added
friendly_nameto sensor definition in config.yml. - Sensor
classcan be now anything from binary_sensor (door, garage_door, window, motion, moving, opening, smoke, vibration and more). Keep in mind that not all Miio events are supported yet! Listed above are supported. - Sensor
classcan be now anything from sensor (humidity, illuminance, temperature, pressure and more). Keep in mind that not all Miio events are supported yet! Listed above are supported.
- Due to changed method of entity_id generation, after update, all entities will have new entity_ids.
You can remove old entities before update via
Settings -> Entity registrywithmiio_gatewaytag. Then you can update this component and restart HA. After restart new entities will be visible – you'll be able to change its entity_id via "Entity registry" too.
miio_gateway.button_actionevent changed tomiio_gateway.actionclick_typeevent param changed toevent_typesingle_clickchanged toclicklong_presschanged tolong_click_presslong_releasechanged tolong_click_release
Not supported but likely to work with:
- Smoke and gas sensors.
- Occupancy detectors.
- Plug switches.
- Locks.
- Smart Cubes.
- Remotes(?).
- Relays(?).
- Curtains(?).