Xiaomi Gateway Integration

I’ve noticed that not only do the new square buttons not support hold, but they don’t support a fast double click. You really have to space it out for it to detect double click.

This is true for both the HA component and the mobile app. The old circular buttons do not have this problem.

Additionally, I too am experiencing the frozen on motion detectors on HA restart. I think this has only been affecting me since the last firmware update.

P.S. I came across someone on Discord that had gotten their Xiaomi temperature sensor working without a gateway using a generic USB ZigBee stick. So there may be further avenues open for Xiaomi integration in the future.

P.P.S. I pointed them here as you can see below :slight_smile:

1 Like

I really wanted to avoid getting a Xiaomi gateway (mostly due to slow order time and my need for instant gratification), so I spent the last 4 or 5 days trying to get these devices to communicate directly with HASS. I even gave in, bought a SmartThings hub this evening, and tried using the SmartThings community device handlers, but couldn’t get them to work how I wanted (though had some success). After much frustration, I was finally able to get temperature imported into the HA dashboard.

I was able to verify that I could receive data after messing around with bellows, and that made me finally realize that bellows fails during the pairing process to enumerate endpoints, device type, clusters, etc… I do not know enough about the Zigbee protocol or devices to really understand what is failing here, but I found that it is still using the standard Home Automation profile (0x0104 or 260), and (I guess) standard temp/humidity clusters (0x0502/1026 & 0x0505/1029). By adding these clusters & attributes directly to the zigbee sqlite database, I first managed to get bellows/hass to update their values in the attributes table, and just now, was able to get it displayed in the dashboard.

Proceed with caution when touching these database file, I don’t want anyone to accidently blow away their HASS install.

My device IEEE address “00:15:8d:00:01:87:34:37” / NWK “11984” - generated automatically into “devices” table when I tried to pair. I had to add just about everything else manually.

CREATE TABLE devices (ieee ieee, nwk, status);
INSERT INTO "devices" VALUES('00:15:8d:00:01:87:34:37',11984,0);
CREATE TABLE endpoints (ieee ieee, endpoint_id, profile_id, device_type device_type, status);
INSERT INTO "endpoints" VALUES('00:15:8d:00:01:87:34:37',1,260,302,1);
CREATE TABLE clusters (ieee ieee, endpoint_id, cluster);
INSERT INTO "clusters" VALUES('00:15:8d:00:01:87:34:37',1,0);
INSERT INTO "clusters" VALUES('00:15:8d:00:01:87:34:37',1,3);
INSERT INTO "clusters" VALUES('00:15:8d:00:01:87:34:37',1,1026);
INSERT INTO "clusters" VALUES('00:15:8d:00:01:87:34:37',1,1027);
INSERT INTO "clusters" VALUES('00:15:8d:00:01:87:34:37',1,1029);
INSERT INTO "clusters" VALUES('00:15:8d:00:01:87:34:37',1,65355);
CREATE TABLE attributes (ieee ieee, endpoint_id, cluster, attrid, value);
INSERT INTO "attributes" VALUES('00:15:8d:00:01:87:34:37',1,0,4,'XIAOMI TEMP');
INSERT INTO "attributes" VALUES('00:15:8d:00:01:87:34:37',1,1026,1,0);
INSERT INTO "attributes" VALUES('00:15:8d:00:01:87:34:37',1,1029,1,0);
INSERT INTO "attributes" VALUES('00:15:8d:00:01:87:34:37',1,0,5,X'6C756D692E73656E736F725F6874');
INSERT INTO "attributes" VALUES('00:15:8d:00:01:87:34:37',1,1026,0,872);
INSERT INTO "attributes" VALUES('00:15:8d:00:01:87:34:37',1,1029,0,4153);
CREATE TABLE output_clusters (ieee ieee, endpoint_id, cluster);
INSERT INTO "output_clusters" VALUES('00:15:8d:00:01:87:34:37',1,0);
INSERT INTO "output_clusters" VALUES('00:15:8d:00:01:87:34:37',1,4);
INSERT INTO "output_clusters" VALUES('00:15:8d:00:01:87:34:37',1,65535);

I do not know how to get this to work automatically, I only that by manually filling in the data that endpoint/cluster enumeration failed to find it works.

2017-07-20 23:27:44 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 139923862522568: Sending {'id': 2, 'event': {'event_type': 'state_changed', 'origin': 'LOCAL', 'time_fired': datetime.datetime(2017, 7, 21, 5, 27, 44, 822620, tzinfo=<UTC>), 'data': {'old_state': <state sensor.xiaomi_temp_lumisensor_ht_01873437_1=44.96; unit_of_measurement=°F, friendly_name=XIAOMI TEMP lumi.sensor_ht @ 2017-07-20T23:25:38.183113-06:00>, 'new_state': <state sensor.xiaomi_temp_lumisensor_ht_01873437_1=43.879999999999995; unit_of_measurement=°F, friendly_name=XIAOMI TEMP lumi.sensor_ht @ 2017-07-20T23:27:44.822513-06:00>, 'entity_id': 'sensor.xiaomi_temp_lumisensor_ht_01873437_1'}}, 'type': 'event'}

From desk to fridge

I’m going to work on figuring out the buttons (I have a bunch of them), and eventually maybe the cube.

5 Likes

Does anyone here have an idea how to get the cube running with my screenshots above ? It seems that has can well eas states I just need to somehow get them into Hass

Have you read the README file? https://github.com/Danielhiversen/homeassistant/blob/master/README.md

You can also find some examples of how I use it here: https://github.com/Danielhiversen/home-assistant_config/search?utf8=✓&q=cube_action&type=

2 Likes

The problem is that Hass won’t give me event type cube but as u can see above I get my cube movements … so how to integrate them as events in hass? Do u see the events in Hass events page in Frontend?

I assume that 0.50 is actually the dev branch? Let me try this tonight

Yes, an event should be fired.

As u can see I see my movements of the cube but don’t see event type in frontend and am I right that key is password in app I can randomly create ?

I do not think you should see the event in the frontend. I think that are only events that you can fire manually.
But you should see it in the log, if you have enabled the correct log level.

Have you tried to make an automation?

I just need to use Hass dev branch delete custom component right ?

Yes, and change sid: to mac:

Yeah se above I posted debug output of component but adding those automation doesn’t work it just won’t add my automation dunno why I used the example for automation … ran configure check all right but this automation is just not added to Hass

1 Like

http://www.gearbest.com/kitchen-appliances/pp_366782.html

can this be controlled?

Has anyone tried integrating Philips/Xiaomi smart LED bulbs? They are controllable via Mi Home and don’t require the gateway to work. Called “Philips Connected Bulb” in Mi Home.

10 bucks on gearbest.

http://www.gearbest.com/smart-lighting/pp_644095.html

EDIT: So apparently it doesn’t have developer mode, yet.

In Your PR in HA dev branch one thing is different than usual. States of motion sensors and switches are True/False and not on/off. It’s a mistake or purpose change?

EDIT
After HA restart all motion sensors have state ‘unknown’.

1 Like

It’s no subdevice of the xiaomi gateway. Therefor another HA platform/component is needed to contol the device. I assume the somehow unified xiaomi network protocol is used. If you are able to extract the token you can give it a try. The mirobo component or my xiaomiplug custom_component will be a good starting point.

That is a bug. I think I have fixed it now: https://github.com/home-assistant/home-assistant/compare/dev...xiaomi_bug_fix?quick_pull=1

All sensors will have state unknown until data is received from the sensor. Before the initial state was assumed.

Edit: Thanks for reporting it,

3 Likes

@Danielhiversen Yes, this fixed issue. Now states are on/off and after HA restart all binary_sensors states are off.

By the way. Great job with this component and merging it! The community is very grateful :grinning:

1 Like

Does anybody want to prepare a table (markdown) of supported/unsupported devices for the HA documentation? The columns “product title”, " internal model name", “sensor type”, " sensor

1 Like