Xiaomi Gateway Integration

Currently use rave’s bench.
Put it into custom components folder than manually sim linked to the root (as git puts into a different directory). Can somebody please post simple solution to switch to Danielhiversen branch?
Or even maybe rm -rf and than how to clone the git into the custom_components folder?

Sorry to bump it up - but maybe someone can lay a helping hand on this one?

Awesome work, I’ve used Danielhiversen repo and I’ve been able to use xiaomi switches to drive hue light, amazing!
What I still not understand is if I can use the temperature sensor to trigger an event.
I’ve put one in bathroom, and I want to turn on a smart plug (osram, connected to hue, seen as light) when the humidity in the room reaches a particular threshold (when the shower is open) any idea if I can accomplish this?

You should read through an examples page on home-assistant site

  trigger:
    platform: numeric_state
    entity_id: sensor.your.xiaomi.bathroom.entity.id
    above: your_value

I ended up using it as a trigger and condition since it doesn’t work most of the time if used only as a trigger:

 trigger:
   - platform: numeric_state
     entity_id: sensor.humidity_158d00011823a5
     value_template: "{{ states.sensor.humidity_158d00011823a5.state | float }}"
     above: 70
   - platform: time
     minutes: '/15'
  condition:
    condition: and
    conditions:
    - condition: time
      after: '07:00:00'
      before: '21:00:00'
    - condition: numeric_state
      entity_id: sensor.humidity_158d00011823a5
      value_template: "{{ states.sensor.humidity_158d00011823a5.state | float }}"
      above: 70.00

I didn’t really want to answer you because I do it the noob way because I don’t quite understand git, or linux commands yet. But since nobody else is… and my apologies if I have misunderstood your question.

Basically, when I want to switch branches or update I just navigate to the custom components directory - delete everything, since xiaomi is all I have in there and drag and drop the new files. Then restart hass.

So if you want to do it the wrong way here is my windows step by step.

1) I spend about 15 mins scrolling through the thread until I can find a post by @Danielhiversen with a link to his repo and click it. I do this because I always plan to bookmark or save the link next time. ( https://github.com/danielhiversen/homeassistant )

2) I click the green clone or download button and then select download as zip. ( https://github.com/Danielhiversen/homeassistant/archive/master.zip )

3) Usually I stop home-assistant, then navigate to the hass config directory on my windows PC. (I have the relevant directory shared by samba to make things easy for me.)

4) I delete everything in that folder.

5) I copy everything from the components folder in the zip I downloaded from github into the custom_components directory in my hass config directory. It looks the same as the first pic except for the pycache folder, this will be created on first run.

6) Restart hass and branch is switched.

7) Swear at the screen because I have now lost all my chromecast devices again and will need to keep restarting until I get them back.

This is how I do it from command line in Linux.
You need to replace the path with your path.
See the section that has Daniels version. It overwrites whatever is currently there;

1 Like

after chanhges this folder needs to be deleted?

I don’t think so, but I find CTRL-A easy than selective selecting. Half the time I don’t delete at all and just drag it over the top.

Just received and tested the wireless switch, working like a champ…

is the battery level indicator reliable? mine already came at 50%

Well probably depend on boxing and selling time, they arrive already active (instead of, for example, hue accessories that have a little strip between battery contacts) so maybe they discharge.
Mine arrive with 65% of battery

Hi all,

Today I received my motion sensor. I have added it to HAA and the sensior is reconized.

However:
HAA says that there is no motion detected now (1200) Can some one please tell me how to add the sensor? or why it is not working?

HAA log gives the following errror:

17-05-06 14:02:25 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: required key not provided @ data[‘action’]. Got None. (See /home/homeassistant/.homeassista$

automation.yaml:

- alias: Motion Test to turn light on
  trigger:
    - platform: state
      entity_id: binary_sensor.motion_sensor_158d00015c9eef
      to: 'True'
  condition:
    - condition: state
      entity_id: sensor.set_hold_mode
      state: 'home'  
  action:
    - service: light.turn_on
      data:
        entity_id: light.master
        color_temp: 154
        brightness: 255

configuration.yaml:

xiaomi:
 gateways:
   - sid:
     key: xxxxxxxxxxxxxxx

oh yeah! when I wrote I hadn’t remember that the battery was already plugged in…
Xiaomi really should use those little strips

Maybe thats why they releasing the new aqara sensors, old batteries are already dying :joy:

Motion sensor has states on and off not false and true.
Move entity_id one level up in your action section.

but now it shows 68% instead of 50% as it showed awhile ago

@Danielhiversen I use your fork and sometimes (once, twice a day) I have in log something like that:

2017-05-08 07:37:01 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d00014d0a27 is taking over 10 seconds
2017-05-08 07:37:01 ERROR (Thread-5) [custom_components.xiaomi] Cannot connect to Gateway
2017-05-08 07:37:01 ERROR (Thread-5) [custom_components.xiaomi] No data in response from hub None
2017-05-08 07:37:32 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d00014d0a27 is taking over 10 seconds
2017-05-08 07:37:32 ERROR (Thread-12) [custom_components.xiaomi] Cannot connect to Gateway
2017-05-08 07:37:32 ERROR (Thread-12) [custom_components.xiaomi] No data in response from hub None

This usually applies to the motion sensor but sometimes also to the temperature/humidity sensor. Is it a WiFi problem? On the router I wrote a script that pings Xiaomi Gateway and during these errors there are no delays.

I’m very interested to hear reports from people who are using the native zigbee support from 0.44, and whether they are able to see or even use the Xiaomi sensors.

4 Likes

First post here, first of all I just wanted to say thank you :

Then, I have 3 questions :

  • what are the differences between @Danielhiversen and @rave version (I installed @rave one)
  • is it possible to replace arming/disarming from xiaomi with an automation (I mean if door is opened fired the gateway sound) or should I take an other device for making noise :slight_smile:
  • is it possible to cut internet from xiaomi gateway (this way i’m sure my data is not on chinese servers anymore ?)

Thank you for your work.

  1. Good question. In general @rave repo is out of date. I would go with @Danielhiversen repo as it has support for gateway ring, gateway light sensor and maybe more. I switched a few weeks back
  2. With daniels repo you can create an automation to sound the gateway based on sensor and rules (I didnt do it myself but all the functionality is there)
  3. Yes - you need to configure your router to do it. Depends on router. I’m still looking into this with my Unifi Edgerouter, but I know it’s possible.
  1. Ok, thanks.
  2. So I’ll switch tonight
  3. So no way to disable it on the gateway itself :confused: I will go with my router but I’m not sure it’s able to do firewalling this way…

No way to disable on the gw itself.
This is how xiaomi provides remote control as well as offshoring all your sensor data (benefits vs risks are for individuals to decide)