Xiaomi Gateway Integration

Just enable the debug log. Because of the official component it looks like this now:

logger:
  default: warn
  logs:
    homeassistant.components.xiaomi: debug
    homeassistant.components.binary_sensor.xiaomi: debug
    homeassistant.components.sensor.xiaomi: debug
    homeassistant.components.light.xiaomi: debug
    homeassistant.components.switch.xiaomi: debug

What is an “alert” for the Xiaomi cube? Throw it into the wall? Sink it in water? :_)

Something like an earth quake. :wink:

Isn’t that tap_twice event?

Huh? If I put the cube on a table and pass by the cube reports an “alert”. If I tap twice on the cube it reports “tap_twice”.

Just build a game for your guests: Connect each event to a custom ringtone of the gateway and ask your guests to discover all 9 gestures. :stuck_out_tongue: This could be the automation:

# automation
automation:
  - alias: Cube flip90
    trigger:
      platform: event
      event_type: cube_action
      event_data:
        entity_id: binary_sensor.cube_158d00011a052e
        action_type: flip90
    action:
      - service: script.turn_on
        entity_id: script.play_sound
        data:
          variables:
            ringtone_vol: 8
            ringtone_id: 10002
  
  - alias: Cube flip180
    trigger:
      platform: event
      event_type: cube_action
      event_data:
        entity_id: binary_sensor.cube_158d00011a052e
        action_type: flip180
    action:
      - service: script.turn_on
        entity_id: script.play_sound
        data:
          variables:
            ringtone_vol: 8
            ringtone_id: 10003
  
  - alias: Cube move
    trigger:
      platform: event
      event_type: cube_action
      event_data:
        entity_id: binary_sensor.cube_158d00011a052e
        action_type: move
    action:
      - service: script.turn_on
        entity_id: script.play_sound
        data:
          variables:
            ringtone_vol: 8
            ringtone_id: 10009
  
  - alias: Cube tap_twice
    trigger:
      platform: event
      event_type: cube_action
      event_data:
        entity_id: binary_sensor.cube_158d00011a052e
        action_type: tap_twice
    action:
      - service: script.turn_on
        entity_id: script.play_sound
        data:
          variables:
            ringtone_vol: 8
            ringtone_id: 10008
  
  - alias: Cube shake_air
    trigger:
      platform: event
      event_type: cube_action
      event_data:
        entity_id: binary_sensor.cube_158d00011a052e
        action_type: shake_air
    action:
      - service: script.turn_on
        entity_id: script.play_sound
        data:
          variables:
            ringtone_vol: 8
            ringtone_id: 10007
  
  - alias: Cube swing
    trigger:
      platform: event
      event_type: cube_action
      event_data:
        entity_id: binary_sensor.cube_158d00011a052e
        action_type: swing
    action:
      - service: script.turn_on
        entity_id: script.play_sound
        data:
          variables:
            ringtone_vol: 8
            ringtone_id: 10006
  
  #- alias: Cube alert
  #  trigger:
  #    platform: event
  #    event_type: cube_action
  #    event_data:
  #      entity_id: binary_sensor.cube_158d00011a052e
  #      action_type: alert
  #  action:
  #    - service: script.turn_on
  #      entity_id: script.play_sound
  #      data:
  #        variables:
  #          ringtone_vol: 8
  #          ringtone_id: 10005
  
  - alias: Cube free_fall
    trigger:
      platform: event
      event_type: cube_action
      event_data:
        entity_id: binary_sensor.cube_158d00011a052e
        action_type: free_fall
    action:
      - service: script.turn_on
        entity_id: script.play_sound
        data:
          variables:
            ringtone_vol: 8
            ringtone_id: 10004
  
# script
script:
  play_sound:
    sequence:
      - condition: state
        entity_id: input_boolean.mute_gateway_sounds
        state: 'off'
      - service: xiaomi.play_ringtone
        data_template:
          gw_mac: !secret xiaomi_sid
          ringtone_id: "{{ ringtone_id }}"
          ringtone_vol: "{{ ringtone_vol }}"

The alert event happens to often randomly for my taste.

1 Like

You are right. Channel 1 (the right button) and the dual channel (both_click) works fine. Channel 0 is utterly broken with firmware 1.4.1_149.0143. The new firmware has no benefits so far. :frowning:

Hi friends,
I have xiaomi gateway an sensors. I can connecting and control gateway on Iphone but I don’t add subdevicies.
How can add subdevice?

I haven’t tried yet. But Home gw has default automation for the wireless switch in case of double click to arm or disarm the alarm. That automation should be available with the virtual event too, my guess.

Well still can’t get a single “alert” action on cube - any tips?

Ans also instead of swing get the following with chinese lady speaking out of gateway
2017-08-12T22:07:34.034435+03:00 home hass[10638]: #033[32m2017-08-12 22:07:34 INFO (MainThread) [homeassistant.core] Bus:Handling <Event cube_action[L]: entity_id=binary_sensor.cube_15xxx, action_type=iam>#

Regarding the subdevice question.

I cannot connect the power outlet that I manage with xiaomi, but I have the indication that is supported. It’s the following:
http://www.gearbest.com/living-appliances/pp_344666.html1

Should I install some kind of add-on to control this power outlet?

Tks!

Hi fastrax!

I also have this wifi plug. Were you able to solve this issue??

This (“iam”) is the pairing event. I don’t remember. Does the cube have a pairing button inside? The voice appears if you press the pairing button of an already paired device. This happens on the wireless wall switch sometimes if you press both buttons at the same time, because the device doesn’t have a pairing button and the pairing is bound to this combination.

What’s the firmware version of your gateway? Try to add the device without the mi home app: Press the button of the gateway three times and the pairing button of the device once. If the device was already paired with another gateway (by accident?) press the pairing button for 20 seconds. The device/blue led will blink a few times. Now you can pair the device again: Gateway button 3 times + Pairing button of the device once.

I wrote a custom component to integrate the xiaomi wifi plug into home assistant:

It’s discussed here: https://community.home-assistant.io/t/xiaomi-mi-wifi-plug-air-purifier/

1 Like

thanks! mine is the single button switch so I am guessing that is the same… dead dead dead and useless now :frowning:

To clarify it: There is a “wifi version” and a “zigbee” version. The zigbee version works fine with the xiaomi component, because it’s zigbee and paired like any other device. The wifi version needs another protocol and must be integrated separately into home assistant. f.e. by the xiaomiplug custom component.There is no official support of the device so far.

Furthermore: The wifi version cannot measure power consumption / load / is used. The zigbee version reports this values. If you want to buy one of these devices: Take the zigbee one. :wink:

Did I get it right: It’s possible to create a automation (at the mi home app), which connects a wireless button (or another subdevice) which the arm/disarm function of the gateway? In this case the automation could be triggered by a virtual button event.

Yes and such automation was already activated on Mi Gateway first time I installed it.

1 Like