Page 22 of 123

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

Posted: Wednesday 18 January 2017 22:47
by deennoo
works for me two,

maybe is your too professional distro, can you made a vm on it and run a "classic" debian ?

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

Posted: Wednesday 18 January 2017 23:06
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.

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

Posted: Thursday 19 January 2017 5:40
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.

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

Posted: Thursday 19 January 2017 5:43
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.

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

Posted: Thursday 19 January 2017 8:48
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}"}

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

Posted: Thursday 19 January 2017 10:07
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...

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

Posted: Thursday 19 January 2017 10:12
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!

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

Posted: Thursday 19 January 2017 11:37
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)

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

Posted: Thursday 19 January 2017 14:38
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

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

Posted: Thursday 19 January 2017 14:50
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 2020 times

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

Posted: Thursday 19 January 2017 15:18
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.

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

Posted: Thursday 19 January 2017 19:18
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)

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

Posted: Thursday 19 January 2017 19:23
by deennoo
Xiaomi API doesn't provid info about wifi plug, as they aren't link to the gateway.

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

Posted: Thursday 19 January 2017 19:27
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.

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

Posted: Thursday 19 January 2017 19:34
by corbin
@levynger, thanks. are you going to also add in support for ctrl_neutral1 - https://translate.google.com/translate? ... edit-text=

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

Posted: Thursday 19 January 2017 19:47
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..

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

Posted: Thursday 19 January 2017 20:04
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.

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

Posted: Thursday 19 January 2017 21:00
by corbin
Thanks, I was attempting to add the write support myself but wasn't sure why it was missing those models.

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

Posted: Thursday 19 January 2017 21:55
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;
	}

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

Posted: Friday 20 January 2017 0:08
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