Xiaomi Smart Home Suite (very cheap) compatibilty?

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by deennoo »

works for me two,

maybe is your too professional distro, can you made a vm on it and run a "classic" debian ?
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
mKotek
Posts: 68
Joined: Wednesday 30 December 2015 23:54
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Poland
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by mKotek »

Mat2Vence wrote:Any idea why I cannot get the latest beta version update of domoticz? I am getting an error at the very end of the download
If anyone has an issue updating beta Domoticz from web, just go to domoticz folder and run updatebeta script from there. It works always and the web version sometimes fails for no apparent reason.
Michal 'Kotek', greetings from Poland. Zapraszam na mój blog o automatyce domowej po polsku: http://www.ukotka.com.
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by corbin »

levynger wrote: @corbin, im getting invalid key ack from the gateway on any command i construct using the string from "GetGatewayKey();" function.
is it working for you?
try adding some log outputs to that function, make sure the password and token values are there, ie:

Code: Select all

std::string XiaomiGateway::GetGatewayKey()
{
	_log.Log(LOG_STATUS, "GetGatewayKey: m_GatewayPassword is %s", m_GatewayPassword.c_str());
	const unsigned char *key = (unsigned char *)m_GatewayPassword.c_str();
	unsigned char iv[AES_BLOCK_SIZE] = { 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28, 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58, 0x56, 0x2e };
	_log.Log(LOG_STATUS, "GetGatewayKey: m_token is %s", m_token.c_str());
	unsigned char *plaintext = (unsigned char *)m_token.c_str();
	unsigned char ciphertext[128];

	AES_KEY encryption_key;
	AES_set_encrypt_key(key, 128, &(encryption_key));
	AES_cbc_encrypt((unsigned char *)plaintext, ciphertext, sizeof(plaintext) * 8, &encryption_key, iv, AES_ENCRYPT);

	char gatewaykey[128];
	for (int i = 0; i < 16; i++)
	{
		sprintf(&gatewaykey[i * 2], "%02X", ciphertext[i]);
	}
	_log.Log(LOG_STATUS, "GetGatewayKey: gatewaykey %s", gatewaykey);
	return gatewaykey;
}
It will not be able to calculate a valid key until the gateway has returned the first token, which should be sent every 10 seconds in the gateway heartbeat message.
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: RE: Re: RE: Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by corbin »

murtadin wrote: who can give me minimal system requirements? Which libs and kernel options are required in order to run domoticz with xiaomi gateway? Why no errors during configure an make?

Help - this driving me crazy ))
Try inspecting the inputs and outputs of the GetGatewayKey as I showed in the post above. Will give me a clue as to what is going wrong.

I can't help much with your Gentoo configuration - you know much more about it than me.
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
User avatar
vetalok
Posts: 22
Joined: Friday 30 December 2016 12:40
Target OS: Linux
Domoticz version: 3.6273
Location: Lviv, Ukraine
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by vetalok »

corbin wrote:
vetalok wrote: Emm... When I enable LED from MiHome - Domoticz off light
I've made a couple of changes, you will now need to turn the light on from the app to get it to detect in Domoticz, and I've added some extra log output. Can you try that and post the output if it still isn't working?

Problem fixed) Thank you.
But brightness not working ;(

Log:

Code: Select all

2017-01-19 09:43:30.308 User: vetal initiated a switch command (17/лампа gateway, кімната 1 (XIaomi)/Set Level)
2017-01-19 09:43:30.308 XiaomiGateway: Setting brightness not implemented, will try to fix this later
2017-01-19 09:43:30.308 (XiaomiGateway) Lighting Limitless/Applamp (лампа gateway, кімната 1 (XIaomi))
2017-01-19 09:44:18.553 XiaomiGateway: rgb received value: 0
2017-01-19 09:44:18.553 XiaomiGateway: setting on to false
2017-01-19 09:44:18.553 XiaomiGateway: Updating existing - nodeid: f0b4299a6a3e
2017-01-19 09:44:18.553 (XiaomiGateway) Lighting Limitless/Applamp (лампа gateway, кімната 1 (XIaomi))
2017-01-19 09:44:18.556 {"cmd":"report","model":"gateway","sid":"f0b4299a6a3e","short_id":0,"data":"{\"rgb\":0}"}
2017-01-19 09:44:27.475 XiaomiGateway: rgb received value: 1694498815
2017-01-19 09:44:27.475 XiaomiGateway: setting on to true
2017-01-19 09:44:27.475 XiaomiGateway: Updating existing - nodeid: f0b4299a6a3e
2017-01-19 09:44:27.475 (XiaomiGateway) Lighting Limitless/Applamp (лампа gateway, кімната 1 (XIaomi))
2017-01-19 09:44:27.477 {"cmd":"report","model":"gateway","sid":"f0b4299a6a3e","short_id":0,"data":"{\"rgb\":1694498815}"}
2017-01-19 09:44:42.431 XiaomiGateway: rgb received value: 0
2017-01-19 09:44:42.431 XiaomiGateway: setting on to false
2017-01-19 09:44:42.431 XiaomiGateway: Updating existing - nodeid: f0b4299a6a3e
2017-01-19 09:44:42.431 (XiaomiGateway) Lighting Limitless/Applamp (лампа gateway, кімната 1 (XIaomi))
2017-01-19 09:44:42.433 {"cmd":"report","model":"gateway","sid":"f0b4299a6a3e","short_id":0,"data":"{\"rgb\":0}"}
2017-01-19 09:44:48.413 XiaomiGateway: rgb received value: 1694498815
2017-01-19 09:44:48.413 XiaomiGateway: setting on to true
2017-01-19 09:44:48.413 XiaomiGateway: Updating existing - nodeid: f0b4299a6a3e
2017-01-19 09:44:48.414 (XiaomiGateway) Lighting Limitless/Applamp (лампа gateway, кімната 1 (XIaomi))
2017-01-19 09:44:48.416 {"cmd":"report","model":"gateway","sid":"f0b4299a6a3e","short_id":0,"data":"{\"rgb\":1694498815}"}
2017-01-19 09:45:00.378 XiaomiGateway: rgb received value: 0
2017-01-19 09:45:00.378 XiaomiGateway: setting on to false
2017-01-19 09:45:00.827 XiaomiGateway: Updating existing - nodeid: f0b4299a6a3e
2017-01-19 09:45:00.827 (XiaomiGateway) Lighting Limitless/Applamp (лампа gateway, кімната 1 (XIaomi))
2017-01-19 09:45:00.884 {"cmd":"report","model":"gateway","sid":"f0b4299a6a3e","short_id":0,"data":"{\"rgb\":0}"}
2017-01-19 09:45:55.235 XiaomiGateway: rgb received value: 1694498815
2017-01-19 09:45:55.235 XiaomiGateway: setting on to true
2017-01-19 09:45:55.235 XiaomiGateway: Updating existing - nodeid: f0b4299a6a3e
2017-01-19 09:45:55.236 (XiaomiGateway) Lighting Limitless/Applamp (лампа gateway, кімната 1 (XIaomi))
2017-01-19 09:45:55.238 {"cmd":"report","model":"gateway","sid":"f0b4299a6a3e","short_id":0,"data":"{\"rgb\":1694498815}"}
2017-01-19 09:46:04.191 XiaomiGateway: rgb received value: 1677786953
2017-01-19 09:46:04.191 XiaomiGateway: setting on to true
2017-01-19 09:46:04.191 XiaomiGateway: Updating existing - nodeid: f0b4299a6a3e
2017-01-19 09:46:04.191 {"cmd":"report","model":"gateway","sid":"f0b4299a6a3e","short_id":0,"data":"{\"rgb\":1677786953}"}
2017-01-19 09:46:31.117 XiaomiGateway: rgb received value: 1677787021
2017-01-19 09:46:31.117 XiaomiGateway: setting on to true
2017-01-19 09:46:31.117 XiaomiGateway: Updating existing - nodeid: f0b4299a6a3e
2017-01-19 09:46:31.117 {"cmd":"report","model":"gateway","sid":"f0b4299a6a3e","short_id":0,"data":"{\"rgb\":1677787021}"}
2017-01-19 09:46:34.106 XiaomiGateway: rgb received value: 1681064191
2017-01-19 09:46:34.106 XiaomiGateway: setting on to true
2017-01-19 09:46:34.106 XiaomiGateway: Updating existing - nodeid: f0b4299a6a3e
2017-01-19 09:46:34.107 {"cmd":"report","model":"gateway","sid":"f0b4299a6a3e","short_id":0,"data":"{\"rgb\":1681064191}"}
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by ben53252642 »

Just had a heap of the appliance modules delivered, are you guys finding its near impossible to plug in a 2 prong appliance? 3 prong plugs in fine...
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by corbin »

get a thin screwdriver or something else that fits in the 3rd hole, and push it in, then plug in your 2 prong device. of course don't do this whilst plugged into the mains power!
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
murtadin
Posts: 62
Joined: Saturday 31 December 2016 15:33
Target OS: Linux
Domoticz version: beta
Contact:

Re: RE: Re: RE: Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by murtadin »

corbin wrote:
murtadin wrote: who can give me minimal system requirements? Which libs and kernel options are required in order to run domoticz with xiaomi gateway? Why no errors during configure an make?

Help - this driving me crazy ))
Try inspecting the inputs and outputs of the GetGatewayKey as I showed in the post above. Will give me a clue as to what is going wrong.

I can't help much with your Gentoo configuration - you know much more about it than me.
Here it is:

Code: Select all

2017-01-19 12:35:21.364 User: Admin initiated a switch command (16/Xiaomi Smart Plug/On)
2017-01-19 12:35:21.364 0117A188
2017-01-19 12:35:21.364 GetGatewayKey: m_GatewayPassword is 4ih21t6kgdavp7bm
2017-01-19 12:35:21.364 GetGatewayKey: m_token is
2017-01-19 12:35:21.364 GetGatewayKey: gatewaykey FE25EFFDA1230D157A1CF8D4E8A370B1
2017-01-19 12:35:21.514 XiaomiGateway: response {"cmd":"write_ack","sid":"158d000117a188","data":"{\"error\":\"Invalid key\"}"}
2017-01-19 12:35:21.514 (gw.living) Light/Switch (Xiaomi Smart Plug)
levynger
Posts: 87
Joined: Wednesday 21 December 2016 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Israel
Contact:

Re: RE: Re: RE: Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by levynger »

murtadin wrote:
corbin wrote:
murtadin wrote: who can give me minimal system requirements? Which libs and kernel options are required in order to run domoticz with xiaomi gateway? Why no errors during configure an make?

Help - this driving me crazy ))
Try inspecting the inputs and outputs of the GetGatewayKey as I showed in the post above. Will give me a clue as to what is going wrong.

I can't help much with your Gentoo configuration - you know much more about it than me.
Here it is:

Code: Select all

2017-01-19 12:35:21.364 User: Admin initiated a switch command (16/Xiaomi Smart Plug/On)
2017-01-19 12:35:21.364 0117A188
2017-01-19 12:35:21.364 GetGatewayKey: m_GatewayPassword is 4ih21t6kgdavp7bm
2017-01-19 12:35:21.364 GetGatewayKey: m_token is
2017-01-19 12:35:21.364 GetGatewayKey: gatewaykey FE25EFFDA1230D157A1CF8D4E8A370B1
2017-01-19 12:35:21.514 XiaomiGateway: response {"cmd":"write_ack","sid":"158d000117a188","data":"{\"error\":\"Invalid key\"}"}
2017-01-19 12:35:21.514 (gw.living) Light/Switch (Xiaomi Smart Plug)

had the same problem, just found out that i was missing the Gateway password,
please make sure you set in hardware tab the gateway password as indicated in here:
https://www.domoticz.com/wiki/Xiaomi_Ga ... le_Devices
murtadin
Posts: 62
Joined: Saturday 31 December 2016 15:33
Target OS: Linux
Domoticz version: beta
Contact:

Re: RE: Re: RE: Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by murtadin »

levynger wrote:
murtadin wrote:

Code: Select all

2017-01-19 12:35:21.364 User: Admin initiated a switch command (16/Xiaomi Smart Plug/On)
2017-01-19 12:35:21.364 0117A188
2017-01-19 12:35:21.364 GetGatewayKey: m_GatewayPassword is 4ih21t6kgdavp7bm
2017-01-19 12:35:21.364 GetGatewayKey: m_token is
2017-01-19 12:35:21.364 GetGatewayKey: gatewaykey FE25EFFDA1230D157A1CF8D4E8A370B1
2017-01-19 12:35:21.514 XiaomiGateway: response {"cmd":"write_ack","sid":"158d000117a188","data":"{\"error\":\"Invalid key\"}"}
2017-01-19 12:35:21.514 (gw.living) Light/Switch (Xiaomi Smart Plug)

had the same problem, just found out that i was missing the Gateway password,
please make sure you set in hardware tab the gateway password as indicated in here:
https://www.domoticz.com/wiki/Xiaomi_Ga ... le_Devices
Password is set: 4ih21t6kgdavp7bm
Spoiler: show
Screenshot_2017-01-19-12-40-16-082_com.xiaomi.smarthome.png
Screenshot_2017-01-19-12-40-16-082_com.xiaomi.smarthome.png (187.32 KiB) Viewed 1873 times
mKotek
Posts: 68
Joined: Wednesday 30 December 2015 23:54
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Poland
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by mKotek »

I would say, you are missing the m_token value, but this is only from your screenshot. I am still waiting for my Gateway to arrive, so cannot test it myself. If I am mistaken, please let me know, so not to produce useless posts.
Michal 'Kotek', greetings from Poland. Zapraszam na mój blog o automatyce domowej po polsku: http://www.ukotka.com.
Beto4964
Posts: 1
Joined: Tuesday 17 January 2017 5:15
Target OS: Linux
Domoticz version:
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by Beto4964 »

corbin wrote:I haven't published the code that allows control of the smart plugs yet - have a couple of other bits to finish.

You do need the Zigbee version of the plug, the WiFi plug will not work with Domoticz.
Hi, I have bought a lot of WIFI plugs :(

Is still not working the WIFI Plug with Domoticz?

There is some way to start to research it? I mean, how could I help to start a research (maybe doing a wireshark capture)
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by deennoo »

Xiaomi API doesn't provid info about wifi plug, as they aren't link to the gateway.
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
levynger
Posts: 87
Joined: Wednesday 21 December 2016 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Israel
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by levynger »

@corbin,
Added new patch#5 to your github, the Aqara wired wall switch (dual button) now can be turned on/off from domoticz and not only show status.
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by corbin »

@levynger, thanks. are you going to also add in support for ctrl_neutral1 - https://translate.google.com/translate? ... edit-text=
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
levynger
Posts: 87
Joined: Wednesday 21 December 2016 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Israel
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by levynger »

no problem, i can add this, and the 86sw1 as well, however i wont be able to test any, as i dont have these devices..
levynger
Posts: 87
Joined: Wednesday 21 December 2016 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Israel
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by levynger »

@corbin, added patch #6,
ctrl_neutral1 and 86sw1 added.

ctrl_neutral1 write shuld also work, however i cant test this, as i dont have these devices.
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by corbin »

Thanks, I was attempting to add the write support myself but wasn't sure why it was missing those models.
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: RE: Re: RE: Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by corbin »

murtadin wrote: 2017-01-19 12:35:21.364 GetGatewayKey: m_token is
yes this is the problem, try outputting the token values seen below, and also set 'showmessage = true;' to output the heartbeat message received from the gateway. Perhaps a packet sniffer as well to see what message is being sent from the gateway.

Code: Select all

void XiaomiGateway::UpdateToken(const std::string & value)
{
	boost::lock_guard<boost::mutex> lock(m_mutex);
	m_token = value;
}

Code: Select all

else if (cmd == "heartbeat") {
	//update the token and gateway ip address.	
	m_XiaomiGateway->UpdateToken(root["token"].asString());
	m_gatewayip = root["ip"].asString();
	showmessage = true;
	}
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
paszczus
Posts: 8
Joined: Saturday 14 January 2017 11:46
Target OS: Linux
Domoticz version:
Contact:

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?

Post by paszczus »

This is cool that you guys are still working on Xiaomi! You are awesome!
I have ordered 3 more wifi plugs, 2 temperature and humidity sensors, human body sensor, wireless switch and smart door and windows sensor. It will be cool if i can use all of them using Domoticz! :)
Hope that someone who wrote an API to Xiaomi devices will fix wifi plug voltage and power consumption so it can be shown on Domoticz too
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest