Xiaomi Gateway Integration

Im very new to HA but my experince with the Xiaomi gateway is that the I only need to press the buttom and not hold it to register. I noted that automations take a long time to excecute at the moment, but I didn’t look into this.

You can’t see the last trigger on the badges, but I think it would be a excellent addition, e.g. see the cube triggers, and angels for rotation. I used to use Openhab, and there is was tracked by default. I think you can make a custom sensor badge template with this crazy yaml, but I failed to do it. Would be nice though!

Has anyone got this working with the new HASSIO (docker) installation of home assistant?
I’ve tried setting it up as a custom component (even though the description on github says its not working as a Custom component)

As far as i can tell the HASSIO method of installation doesnt give access to the actual components directory

Any chance to get the energy consumption from the Zigbee socket in HA?

Do you mean this one? http://www.gearbest.com/living-appliances/pp_344666.html

It’s supported at @Danielhiversen fork:

Yes, why I do not see it …?

I do have Daniel fork, maybe not updated? Now I forgot where it is the fork, Link for the fork? Thanks

EDIT, I found it and after updating all the custom_components with daniel’s fork.

What is the power consumed? From which date?, Or is it per day, from beginning, or?

Do you know how to enable the HA “logger” to log some received broadcasts/messages of the aqara zigbee plug? You should see something like this:

2017-06-15 09:21:10 DEBUG (Thread-7) [custom_components.xiaomi] PUSH >> <Entity Plug_158d00012a9aa5: off>: {'inuse': '0', 'voltage': 3600, 'power_consumed': '63', 'status': 'off', 'load_power': '0'}
2017-06-15 09:28:05 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (heartbeat) << {'short_id': 25311, 'model': 'plug', 'cmd': 'heartbeat', 'sid': '158d00012a9aa5', 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"63","load_power":"0"}'}
2017-06-15 09:28:05 DEBUG (Thread-3) [custom_components.xiaomi] PUSH >> <Entity Plug_158d00012a9aa5: off>: {'inuse': '0', 'voltage': 3600, 'power_consumed': '63', 'status': 'off', 'load_power': '0'}
2017-06-15 09:35:33 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (heartbeat) << {'short_id': 25311, 'model': 'plug', 'cmd': 'heartbeat', 'sid': '158d00012a9aa5', 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"63","load_power":"0"}'}
2017-06-15 09:35:33 DEBUG (Thread-10) [custom_components.xiaomi] PUSH >> <Entity Plug_158d00012a9aa5: off>: {'inuse': '0', 'voltage': 3600, 'power_consumed': '63', 'status': 'off', 'load_power': '0'}
2017-06-15 09:41:32 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (heartbeat) << {'short_id': 25311, 'model': 'plug', 'cmd': 'heartbeat', 'sid': '158d00012a9aa5', 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"63","load_power":"0"}'}
2017-06-15 09:41:32 DEBUG (Thread-5) [custom_components.xiaomi] PUSH >> <Entity Plug_158d00012a9aa5: off>: {'inuse': '0', 'voltage': 3600, 'power_consumed': '63', 'status': 'off', 'load_power': '0'}

Please post it here.

Hello guys, thanks for all the work you’ve done so far on this integration. started diving into it a couple of days ago and it’s been working very well.

I do have a question. i want to use the alarm function of the bridge (arming it by using a single button press of the xiaomi button and it will be triggered by the door sensor in state open). Is the alarm supported in the integration ?

I saw that on Daniel’s fork in the release notes there is support for Gateway Sensor / Ringtone play. What is gateway sensor ? what does it do ? Are any of the two suitable for my alarm automation use case ?

Thanks all.

The gateway sensor is illumination. The gateway can play some sounds cp. https://github.com/Danielhiversen/homeassistant/pull/6

For example:

- alias: Welcome home
  trigger:
    platform: state
    entity_id: group.all_devices
    to: 'home'
  action:
    - service: xiaomi.play_ringtone
      data:
        ringtone_id: 13
        #ringtone_id: 10003
        ringtone_vol: 8
        gw_sid: xxxxxxxxxxxx
    - service: notify.html5
      data:
        title: Welcome
        message: Welcome back!

The button events of the gateway are not exposed to home assistant, so we cannot use it. You’ve to arm your alarm by another button (the wireless one f.e.). The alarm has to be implemented as automation in home assistant. You cannot re-use the internal logic of the gateway.

1 Like

Thank you for this, exactly what i was looking for. i’ll give it a try once i arrive home.

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