Xiaomi Gateway Integration

Thanks a lot for your help! Works like a charm!

Hey,

I’m running one older Raspberry as my DHCP and DNS Server. This way you can create “segments” in your network. I’m using it to keep guests in a separate IP segment as well as devices in another segment which cannot connect to the internet.

Took me probably an hour to set it up but it gives me full control over my network :slight_smile:

PLUS: I’m running Pi-Hole on the same raspberry and don’t get annoyed with ads anymore!

Bye,
Daniel

1 Like

Hi Rave,
Thanks for your amazing work now we can get xiaomi parts working with ha. Recently i got a new parts (mijia or aqara air conditioner companion) which is officially claimed as both A/C controller and gateway. But I couldn’t get it up with ha. Does your component support this part? BTW i didn’t find the way to activate the ‘developer mode’ of this part so maybe the vendor hasn’t open the interface yet.

1 Like

This sounds very interesting. Would you have some links/tutorials to follow?

I can find tutorials to install and block ads, how did you create the segments and block internet for these?

You used pi-hole only?

Xiaomi product are the ones giving me very few problems. All other brands, including diy, are behaving worse.

Thinking of switching everything to Xiaomi and forget all the rest

A single aqara gateway is limited to 30 devices. Keep it in mind. :wink: Does mains powered devices act as repeater / range extender / zigbee router? It’s unconfirmed AFAIK.

Well, each gateway is 25$ and are radio, night lights, and light sensor, and siren.

I have two, I can get 3-4 no problem with that.

My only complaint is the power switches which needs adaptor. Also Aqara wall switch are not standard here, and I would need the wall socket to be changed

Guys,

Some time Suddenly i get erro about xiaomi, restaet HA resolve it.

how can i know what Causes it?

Invalid config
The following components and platforms could not be set up:

Please check your config

I use dnsmasq as my DNS / DHCP server - it was already running before I found out about pi-hole. I installed pi-hole on top of it.

I know that pi- hole offers an DHCP option as well and you can configure basics via the web GUI - but I don’t know what happens when you start editing the files “behind it”.

What I do at home is basic on subnetting and I don’t know if pi-hole offers this flexibility?!

I’m traveling back from a business trip right now so I can’t go in too deep :slight_smile:

My network segmentation is based on subnetting. Don’t know how familiar you guys are with networking?! One “disadvantage” is, that I have to add all known devices to my DHCP config. But for me it is worth the security and I don’t have thousands of devices!

Just a rough example:
Network is 10.10.0.0 with a subnet mask 255.255.0.0, Default Gateway is 10.10.0.1 and DNS/DHCP is 10.10.0.2

Every unknown client is assigned to the DMZ/Guest range 10.10.0.0 with subnet mask 255.255.255.0 - this way they can only see / access devices within 10.10.0.x

Other known devices are assigned to the known devices range 10.10.1.0 with subnet mask 255.255.0.0 - so they can see everything within 10.10.x.x

Devices that should not access the internet will be assigned for example to 10.10.2.0 with subnet mask 255.255.0.0. BUT I don’t assign a default gateway option to those devices. Because of the subnet mask 255.255.0.0 they have access to the whole network but because they don’t have a Default Gateway, they don’t now how to access the internet.

Ok, someone could say “Hey guests can hack your DNS Server and get access to your whole network this way”. That’s true but my Pi’s don’t allow password login - only cert based login. So it would take a lot of effort :wink:

It might look complicated but it is really easy - once you get the concept and if you are willing to configure (some of) your DHCP. if you want I can create a repo on Github in the next days with a sample configure?

Bye,
Daniel

P.S.: running your own DNS Server would also make it easier if you want to stream non Chinese radio to your Gateway: http://ximiraga.ru/

2 Likes

I am seeing errors like the following a few times a day:

2017-06-17 22:01:32 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d00013fb2d7 is taking over 10 seconds 2017-06-17 22:01:32 ERROR (Thread-3) [homeassistant.components.xiaomi] Cannot connect to Gateway 2017-06-17 22:01:32 ERROR (Thread-3) [homeassistant.components.xiaomi] No data in response from hub None

This seems to some times break my automation that should turn off my lights (and sometimes they stay on all night)

 - alias: Lounge light off after 4 minutes
   trigger:
      - platform: state
        entity_id: binary_sensor.motion_sensor_158d00013fb2d7
        to: 'off'
        for:
          minutes: 4
   condition:
     - condition: state
       entity_id: device_tracker.samsungtv
       state: 'not_home'
   action:
     - service: light.turn_off
       entity_id: light.tv_light

     - service: homeassistant.turn_off
       entity_id: light.mqtt_json_light_lounge

Is anyone else experiencing these issues and if so do you have any workarounds?

First post here and somewhat obvious but… thanks for that link.
P.S.: running your own DNS Server would also make it easier if you want to stream non Chinese radio to your Gateway: http://ximiraga.ru/
For one off things like that, my router (tomato loaded onto a netgear) I just drop the IP and hostname into the static IP address page along with a made up mac address. Could make a custom hosts file there for it but this way its all obvious what I’ve done and easily enabled/disabled. Custom DNS isn’t needed.

Current Version: 0.47.0

Invalid configuration:

The following components and platforms could not be set up:
xiaomi
Please check your config

Does This happen to someone else?

I get it most of the time, restart the the HA and that work.

I installed for the first time today and got that. I’m running the docker version of HASS and did a git clone of https://github.com/Danielhiversen/homeassistant
I needed a
custom_components folder in the config directory and the directory with xiaomi.py needed to be moved to that folder.
ie …config/custom_components/xiaomi.py + all the other stuff at this level

Guys, sorry for noob question, but could you describe how to do it ?

Hello. Maybe someone can help with an automation for the manual alarm in HA. The alarm in my case will be triggered if the door/windows sensor is opened. The issue is that even though the event is registered instead of going from ‘armed_away’ (or armed_home) state to ‘triggered’ it’s going to armed_away/armed_home - pending - triggered.

Has anyone dealt with this ? Is there a way to trigger the alarm directly without having to wait 5-10 seconds in pending. Code below:

alias: 'Arm from button'
trigger:
  - platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d00013f8817
      click_type: single
action:
  - service: alarm_control_panel.alarm_arm_away
    entity_id: alarm_control_panel.alarm
  - service: xiaomi.play_ringtone
    data:
      ringtone_id: 11
      ringtone_vol: 20
      gw_sid: 286c07887d3a
  - service: notify.notify  
    data:
      message: "Alarm armed"

alias: "Alarm away"
#  hide_entity: True
trigger:
  - platform: state
    entity_id: binary_sensor.door_window_sensor_158d000125d9fb
    to: 'on'   
condition:
    condition: state
    entity_id: alarm_control_panel.alarm
    state: armed_away
action:
    service: alarm_control_panel.alarm_trigger
    entity_id: alarm_control_panel.alarm
1 Like

Can you elaborate a bit more on what actually you need help with?

If I understand your question correctly… To reduce/remove the pending time you will change it where configuring alarm_control_panel: as per https://home-assistant.io/components/alarm_control_panel.manual/

alarm_control_panel:

  • trigger_time: 0