Xiaomi Gateway Integration

Hey.

Forgot to mention that what is being shown on frontend are the 2 last template sensors only (sensor.xiaomi_update and sensor.current_xiaomi_version_date).

Aside from that, you either use a scan_interval as I did above (in which sensor value updated hourly), or you use authenticated access to GitHub API, to avoid reaching usage limits quickly.

Once more, hope this helps.

is there a way to give a command line, instead of copying pasting the code every time?

I use the custom_component, and recent HASSBIAN on a pi3

Not sure if I understood your question, can you please explain a bit further?

Hi guys,

I just can’t get the wireless switches to work. Something isn’t happening in between the PUSH >> and the triggering of the automation.

The automation is fine (manually triggered and the action worked). Any clues?

You probably need to post your code here for folks to help out.

  • action:
    • alias: Test
      data:
      entity_id: light.living_room_2
      service: light.toggle
      alias: New Automation
      id: ‘1500457304724’
      initial_state: true
      trigger:
    • event_data:
      entity_ID: binary_sensor.switch_158d0001243f11
      event_type: click
      platform: event

The automation works when manually triggered. As you can see from the log excerpt below, the homeassistant core also logs handling of the click on the switch but does nothing.

Logs:
2017-07-20 15:56:25 DEBUG (Thread-8) [custom_components.xiaomi] PUSH >> : {‘status’: ‘click’}
2017-07-20 15:56:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event click[L]: entity_id=binary_sensor.switch_158d0001243f11, click_type=single>

At the moment whenever there is a code change in Daniel’s fork, I go in gifthub, copy each file, and then paste it in my custom_components directory.

I wonder if there is a faster way to do it with a command line from my pi3

If you follow the procedure I described in the post above, it becomes much easier.

You just have to manually add new symbolic links only when new files/folders are added in the repo (like it happened recently for cover folder).

To update the files from the @Danielhiversen repo every time you need/want, you can use the below bash script I built for myself:

#!/bin/bash
clear
echo "***************************"
echo "* Stopping Home Assistant *"
echo "***************************"
sudo systemctl stop [email protected]
echo "***********************************************************"
echo "* Updating Xiaomi Gateway Home Assistant Custom Component *"
echo "***********************************************************"
sudo -i -u homeassistant bash << EOF
  cd /home/homeassistant/src/homeassistant
  git pull origin master
EOF
echo "*****************************"
echo "* Restarting Home Assistant *"
echo "*****************************"
sudo systemctl start [email protected]

Please bare in mind that this is working properly for me (considering the above post I mentioned previously) and also that my installation was done with Hassbian.

Adapt as needed for you.

2 Likes

I believed your format is wrong. Try like below…

  alias: Test
  trigger:
    platform: event
    event_type: click
    event_data:
        entity_id: binary_sensor.switch_158d0001243f11
        click_type: single
  action:
    service: light.toggle
    entity_id: light.living_room_2
1 Like

Thanks for trying to help. My bad for not posting on pastebin. https://pastebin.com/k45aYMJJ

This was generated using the automation editor tool, which strangely puts action first and then the triggers

Does anyone have xiaomi curtain?

Do you mind sharing the installation manual (hardware), or a video link, I can’t understand how and where does it work

Pastebin looks the same.

Try editing the automations.yaml file yourself. Currently only Chrome is supported. I never use the automation editor as it is easier to edit the file directly.

[Update] I think I saw what you are missing…“click_type: single”?

Yes, it worked! Thanks a ton.

Some good news: The Xiaomi component will be part of the next release of HA (0.50). So there will be no need to use a custom component anymore.

Many people have contributed to this. Lately, @syssi has done a great job to integrate new features. @jcastro is now doing a great job with the documentation:
https://github.com/home-assistant/home-assistant.github.io/pull/3028 . If you would help with the documentation or have comments, it is possible to comment on the pull request.

I have rewritten most of the code for the integration, and since I do not have all the components, some parts of the code is still untested.

One breaking change is that I have replaced sid with the mac address:

xiaomi:
gateways:
- mac:
  key: xxxxxxxxxxxxxxxx

mac can be both the mac address (with colons) and the old sid format.

27 Likes

Let me know if you need help with testing, I have most of the devices except the curtain, 86sw1 and 2.

Cheers

The code is in the dev branch https://github.com/home-assistant/home-assistant
So all testing would be great.
One way to test the dev branch is to set up a development environment https://home-assistant.io/developers/development_environment/

Good to know :wink:

I have reintroduced the most recent devices.

I hope the PR will be accepted without trouble. :slight_smile:

1 Like

Can someone step by step explain me how to integrate the cube? i have binariy sensors but without attributes and event_type cube doesn’t exist :frowning:

apparently i can sniff out all stuff

2017-07-21 01:28:16 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {'data': '{"status":"move"}', 'cmd': 'report', 'model': 'cube', 'sid': '158d000119f77c', 'short_id': 15665}
2017-07-21 01:28:16 DEBUG (Thread-1) [custom_components.xiaomi] PUSH >> <Entity Cube_158d000119f77c: off>: {'status': 'move'}
2017-07-21 01:28:18 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {'data': '{"rotate":"28,500"}', 'cmd': 'report', 'model': 'cube', 'sid': '158d000119f77c', 'short_id': 15665}
2017-07-21 01:28:18 DEBUG (Thread-3) [custom_components.xiaomi] PUSH >> <Entity Cube_158d000119f77c: off>: {'rotate': '28,500'}
2017-07-21 01:28:19 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {'data': '{"rotate":"8,500"}', 'cmd': 'report', 'model': 'cube', 'sid': '158d000119f77c', 'short_id': 15665}
2017-07-21 01:28:19 DEBUG (Thread-5) [custom_components.xiaomi] PUSH >> <Entity Cube_158d000119f77c: off>: {'rotate': '8,500'}
2017-07-21 01:28:19 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {'data': '{"rotate":"27,500"}', 'cmd': 'report', 'model': 'cube', 'sid': '158d000119f77c', 'short_id': 15665}
2017-07-21 01:28:19 DEBUG (Thread-5) [custom_components.xiaomi] PUSH >> <Entity Cube_158d000119f77c: off>: {'rotate': '27,500'}
2017-07-21 01:28:22 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {'data': '{"rotate":"8,500"}', 'cmd': 'report', 'model': 'cube', 'sid': '158d000119f77c', 'short_id': 15665}
2017-07-21 01:28:22 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {'data': '{"rotate":"24,500"}', 'cmd': 'report', 'model': 'cube', 'sid': '158d000119f77c', 'short_id': 15665}
2017-07-21 01:28:22 DEBUG (Thread-1) [custom_components.xiaomi] PUSH >> <Entity Cube_158d000119f77c: off>: {'rotate': '8,500'}
2017-07-21 01:28:23 DEBUG (Thread-8) [custom_components.xiaomi] PUSH >> <Entity Cube_158d000119f77c: off>: {'rotate': '24,500'}
2017-07-21 01:28:24 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {'data': '{"rotate":"-22,500"}', 'cmd': 'report', 'model': 'cube', 'sid': '158d000119f77c', 'short_id': 15665}
2017-07-21 01:28:25 DEBUG (Thread-9) [custom_components.xiaomi] PUSH >> <Entity Cube_158d000119f77c: off>: {'rotate': '-22,500'}
2017-07-21 01:28:26 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {'data': '{"rotate":"23,500"}', 'cmd': 'report', 'model': 'cube', 'sid': '158d000119f77c', 'short_id': 15665}
2017-07-21 01:28:26 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {'data': '{"rotate":"1,160"}', 'cmd': 'report', 'model': 'cube', 'sid': '158d000119f77c', 'short_id': 15665}
2017-07-21 01:28:26 DEBUG (Thread-8) [custom_components.xiaomi] PUSH >> <Entity Cube_158d000119f77c: off>: {'rotate': '23,500'}
2017-07-21 01:28:26 DEBUG (Thread-9) [custom_components.xiaomi] PUSH >> <Entity Cube_158d000119f77c: off>: {'rotate': '1,160'}

but dunno how to integrate thise in hass :frowning: