Xiaomi Gateway Integration

Interested in giving my decoupled Aqara Wall Switch code a try? in decoupled mode when you press the switch, it generates a click(single click) that HA can react to. One big CAVEAT is that you can’t use the Mi Home app’s automation on that switch, otherwise it will generate erroneous clicks when mi home’s native automation routine triggers.

you can find it at my repo [email protected]:tommycheng/homeassistant.git

1 Like

Hello,

Is there a way to create an automation (such as the one in gateway) to switch colors between a preset list when triggered?

Is this automation, what you are looking for?

input_select:
  color_mode:
    name: Color mode
    options:
      - "red"
      - "green"
      - "blue"
    icon: mdi:format-color-fill

automation:
  - alias: Input select triggered
    hide_entity: true
    trigger:
      platform: state
      entity_id: input_select.color_mode
    action:
      - service: light.turn_on
        entity_id: light.gateway_light_28xxxxxxxxxx
        data_template:
          color_name: '{{ states.input_select.color_mode.state }}'
  
  - alias: Next color by wireless button
    trigger:
      - platform: event
        event_type: click
        event_data:
          entity_id: binary_sensor.switch_158d0xxxxxxxxx
          click_type: single
    action:
       - service: input_select.select_next
         entity_id: input_select.color_mode

Every time the wireless button is pushed the color of the gateway changes to the next input_select option.

4 Likes

Works perfectly, thank you.

Although not every color name from the css3 color map (link: CSS Color Module Level 3) works. I was getting the error:

[homeassistant.util.color] unknown color supplied sky default to white

I tried to use rgb_color with no prevail. (was getting: expecting data['rgb_color'] got "[255,255,255]" type errors.)

After some fiddling I found the best matching available colors. For anyone interested these are the color names matching the default scenes in the gateway:

  gateway_color_mode:
    name: Color mode
    options:
      - "darkviolet" #romantic       
      - "hotpink" #pink             
      - "gold" #wheat           
      - "deepskyblue" #sky              
      - "springgreen" #forest          
      - "blue" #tranquil         
      - "white" #white           
    icon: mdi:format-color-fill
2 Likes

Can anyone help with implementing some wifi mini plugs. I am really struggling.

I have the gateway all up and running, I can see the temperature, luminance and humidity all loaded into Home Assistant. I can turn the light on and off etc on the gateway etc.

I also have three mi plug mini’s. I have used miio to find out the token details etc.
However I don’t know what to put into the configuration.yaml to get them working (Or should they be automatically found?). They are all working on the MiHome App, but I can’t seem to load them into the Home Assistant to control them via the UI.

I currently have files all loaded into the custom_components folder on my HASSBIAN.

I have tried everything I can think of. Can anyone give an example of their configuration.yaml or give me to some tips?

Thanks in advance

This could help: Xiaomi mi wifi plug & air purifier - #17 by Regularj

You’ve to setup two plattforms. The one for the xiaomi gateway + zigbee devices and the renamed one of GitHub - xavV/xiaomi to control the plug.

Just installed the new Door/Window sensor which arrive today. Works great in Mi Home app but not in HA. :disappointed:

Log of HA as below:

2017-07-11 18:31:57 DEBUG (Thread-11) [homeassistant.components.xiaomi] >> b'{"cmd":"read","sid":"158d000xxxxxxx"}'
2017-07-11 18:31:57 DEBUG (Thread-11) [homeassistant.components.xiaomi] << {'data': '{"voltage":3055}', 'model': '', 'sid': '158d000xxxxxxx', 'short_id': 60491, 'cmd': 'read_ack'}
2017-07-11 18:31:57 ERROR (Thread-11) [homeassistant.components.xiaomi] Unsupported devices :

Firstly thanks syssi for the advice! I am new to this and really struggling. I will try implementing the xavV version today and renaming it.

I have a quick question though; can’t I use the “switch” that is included in “Xiaomi Gateway Integration” by Rave? I ask because it seems to be more regularly updated and has more development coming with power consumption etc?

With either methodology, should I use the switch the Rave or xavV version, is it just renaming the xiaomi.py file in the switch folder? Or are there other elements which also need to be renamed?

Apologies if this is a total newbie question. Any help would be greatly appreciated. I am also doing a thorough write up of my build for some friends. I will share with the community when completed.

Thanks again. Fastrax

Hi there,

I just looked a bit into the new square aqara switch - I can read the voltage, but I don’t think the gateway forwards the events as the normal Xiaomi components.

Might be a firmware issue.

Furthermore the MiHome Android app can’t add the Aqara switch - using the IOS MiHome app it succeeds.
Strange

No problem. :wink: Nevertheless you are mixing things up. There is a plattform called “xiaomi” from @Rave and a fork from @danielhiversen which implements the xiaomi gateway plus zigbee devices. The xiaomi wifi plug is another protocol. That’s why another home assistant component is needed. This component is called “xiaomi” also annoyingly. Because of the name conflict you have to rename some stuff…

Yes it’s a firmware issue. Just wait for the next release of the local network protocol (xiaomi gateway firmware).

Do you know when it will happen

Nope. It will be a nice surprise for all of us. :slight_smile:

I’m lost :weary: - how can I find the key for the gateway? I can’t seem to get there from the MI Home app - I think maybe the app has changed?

Thanks,

Tom

Used region mainland China?

Yes - I am using mainland China - seems that the instructions at https://github.com/louisZL/lumi-gateway-local-api/blob/master/device_discover.md don’t match up to what I am seeing in my app.

Thanks,

Tom

sure, will try it! thanks :slight_smile:

try Xiaomi Gateway Integration it’s up to date and better explained!

It seems the new Aqara motion sensor lowered its price! http://www.gearbest.com/alarm-systems/pp_659226.html

Thank you!! I was missing the tapping of the screen!

1 Like