Xiaomi Gateway Integration

I just installed Home Assistant, connected the Xiaomi Hub successfully. The sensors (button, motion) seem to work great, but I can’t seem to use it to start a light. Is it ok to post my scene code?

Sure! Just post.

1 Like

@Danielhiversen do you think it’s a good idea to start working on HA documentation for this platform? I would love to help and hopefully see this soon included in HA. I could start working on it and PR on your repo, for example

@syssi Just checked and it is working just fine. I have a followup question though. How do i know what ringtone id is associate to a specific ringtone in the xiaomi app ? Also what is the max ringtone volume. Thanks again for the help.

I think you have to use trial and error. If you click on the ringtone in the mihome app the gateway rings. Try the same at the developer tools -> “services” of home assistant (http://hassbian.local:8124/dev-service):

domain: xiaomi
service: play_ringtone
service data: {"ringtone_id":"13", "ringtone_vol":"8", "gw_sid":"xxxxxxxxxxxx"}

You can write down a mapping. The highest volume is 100(%).

1 Like

@syssi thanks again. I was able to map out the ID - xiaomi app sound name. If anyone is interested you can find below the list

0 - Police car 1
1 - Police car 2
2 - Accident
3 - Countdown
4 - Ghost
5 - Sniper rifle
6 - Battle
7 - Air raid
8 - Bark
9 - None
10 - Doorbell
11 - Knock at a door
12 - Amuse
13 - Alarm clock
14 - None
15 - None
16 - None
17 - None
18 - None
19 - None
20 - MiMix
21 - Enthusiastic
22 - GuitarClassic
23 - IceWorldPiano
24 - LeisureTime
25 - ChildHood
26 - MorningStreamLiet
27 - MusicBox
28 - Orange
29 - Thinker

The ones with none might be reserved for sound recordings in the app

9 Likes

Looks like a new movement sensor is coming from the Aqara line:

Articulating stand will make it even easier to mount for optimum coverage

this I was missing from current sensor

Hi @AlphaJosh,

are you sure, this one is “smart”? I can’t see anything about wifi connection or something similar, that would make this power strip smart?

Hi, can anyone tell me what’s wrong with my code? I just started using HA this week.

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: 52.3878
  longitude: 4.8841
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 3
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Europe/Amsterdam

# Show links to resources in log and frontend
introduction:

# Enables the frontend
frontend:

# Enables configuration UI
config:

http:
  # Uncomment this to add a password (recommended!)
  # api_password: PASSWORD
  # Uncomment this if you are using SSL or running in Docker etc
  # base_url: example.duckdns.org:8123

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time.
history:

# View all events in a logbook
logbook:

# Track the sun
sun:

# Weather Prediction
sensor:
  platform: yr

# Text to speech
tts:
  platform: google

group: !include groups.yaml
automation: !include automations.yaml
xiaomi:
gateways:
- sid:
key: zzz
 automation:
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d0001132962
click_type: single
action:
service: switch.toggle
entity_id: light.living_room

It’s giving me this error:

Jun 16 16:51:08 hassbian systemd[1]: Starting Home Assistant for homeassistant...
Jun 16 16:51:08 hassbian systemd[1]: Started Home Assistant for homeassistant.
Jun 16 16:52:01 hassbian hass[674]: 2017-06-16 16:52:01 ERROR (Thread-1) [homeassistant.util.yaml] duplicate key: "automation"
Jun 16 16:52:01 hassbian hass[674]: in "/home/homeassistant/.homeassistant/configuration.yaml", line 60, column 0
Jun 16 16:52:01 hassbian hass[674]: in "/home/homeassistant/.homeassistant/configuration.yaml", line 65, column 0
Jun 16 16:52:01 hassbian hass[674]: 2017-06-16 16:52:01 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: duplicate key: "automation"
Jun 16 16:52:01 hassbian hass[674]: in "/home/homeassistant/.homeassistant/configuration.yaml", line 60, column 0
Jun 16 16:52:01 hassbian hass[674]: in "/home/homeassistant/.homeassistant/configuration.yaml", line 65, column 0
Jun 16 16:52:01 hassbian hass[674]: Config directory: /home/homeassistant/.homeassistant

There are two things wrong:

  1. A lot of spaces (indents) are missing.
  2. Two sections starts with “automation:”

Just try this:

group: !include groups.yaml
#automation: !include automations.yaml

xiaomi:
  gateways:
    - sid:
      key: zzz

automation:
  - alias: Toggle livingroom light
    trigger:
      platform: event
      event_type: click
      event_data:
        entity_id: binary_sensor.switch_158d0001132962
        click_type: single
    action:
      service: switch.toggle
      entity_id: light.living_room
1 Like

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