Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway)

 

step 1.Connect to wifi Gateway

Download the Xiaomi app https://play.google.com/store/apps/details?id=com.xiaomi.smarthome

Create an account

Add the Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway) in the app (hold button on Plug for 5 seconds to enter discovery mode)

 

Extract key

Folow the instuctions here: https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor

Copy the output

You should get an output something like the following

 

Devices found for server "cn":

--------

MiCloud devices info
Name: Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway)2
Model: chuangmi.plug.212a01
IP: 192.168.2.109
MAC:768:AB:EC:98:99:98
Token: 2408ba10eeb2e7cef627dc0683d

way 1.xiaomi miio raw Integration

Install xiaomi miio raw Integration

Navigate to HACS > Integrations

Three dots top right > Custom repositories

Custom repository URL = https://github.com/syssi/xiaomi_raw

Category = Integration

Add

This may take a while, and there is a posibility you will run into GitHub rate limits

Reboot HA

output

Logger: homeassistant.components.sensor
Source: runner.py:119
Integration: Sensor (documentation, issues)
First occurred: 07:23:21 (2 occurrences)
Last logged: 07:23:45

Setup of sensor platform xiaomi_miio_raw is taking over 10 seconds

 

Add xiaomi miio raw Integration

Configuration > Integrations

Add Integration button

Seach for  'Xiaomi MiIO Raw'

Add

Host: <gateway_ip>

Password:

Access Token: <gateway_token>

Model: Aqara Gateway M1S

If everything went well you should see home assistant add some new devices

 

sensor:


#https://github.com/syssi/xiaomi_raw
  - platform: xiaomi_miio_raw
    name: Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway)
    host: 192.168.2.109
    token: 2408ba10c691feeb2e7cef627dc0683d
    max_properties: 10
    default_properties_getter: get_properties
    default_properties:
      - "{'did': 'power', 'piid': 1, 'siid': 2}"
      - "{'did': 'temperature', 'piid': 6, 'siid': 2}"
      - "{'did': 'indicator_light', 'piid': 1, 'siid': 3}"
      - "{'did': 'on_duration', 'piid': 1, 'siid': 4}"
      - "{'did': 'off_duration', 'piid': 2, 'siid': 4}"
      - "{'did': 'countdown', 'piid': 3, 'siid': 4}"
      - "{'did': 'task_switch', 'piid': 4, 'siid': 4}"
      - "{'did': 'countdown_info', 'piid': 5, 'siid': 4}"
      - "{'did': 'power_consumption', 'piid': 1, 'siid': 5}"
      - "{'did': 'electric_current', 'piid': 2, 'siid': 5}"
      - "{'did': 'voltage', 'piid': 3, 'siid': 5}"
      - "{'did': 'electric_power', 'piid': 6, 'siid': 5}"
  - platform: template
    sensors:
      smart_plug_power:
        unique_id: smart_plug_power
        unit_of_measurement: W
        value_template: "{{ state_attr('sensor.smart_plug', 'electric_power')|int / 100 }}"
        availability_template: "{{ not is_state('sensor.smart_plug', 'unavailable') }}"
        icon_template: "mdi:flash"
 
way 2.
 
way 3.Xiaomi Miot Auto Integration

Comments


Comments are closed