Page 1 of 1

Xiaomi Aqara Temperature Humidity Sensor

Posted: Wednesday 24 January 2018 13:08
by serak
Because "Xiaomi Smart Home Suite" Topic is too big and is not easy to find there answers for questions, I suggest, to make smaller topics for single sensors or for specifics problems.

Here is my question: I've four Aqara temp sensors. All of them shows Battery level 100%. But two of them showed for some time Battery level 84%. Why two of them only and why just for some time? Something wrong in new firmware? What do the sensors show you?

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Sunday 04 February 2018 15:20
by slydiman
It looks like a deep bug inside Domoticz.

The classic Xiaomi temp/hum sensor reports the following json:

Code: Select all

{"cmd":"read_ack","model":"sensor_ht","sid":"***","short_id":***,"data":"{\"voltage\":2985,\"temperature\":\"2338\",\"humidity\":\"3801\"}"}
The Aqara temp/hum/pressure sensor reports the following json:

Code: Select all

{"cmd":"read_ack","model":"weather.v1","sid":"***","short_id":***,"data":"{\"voltage\":2955,\"temperature\":\"2485\",\"humidity\":\"2896\",\"pressure\":\"100100\"}"}
XiaomiGateway.cpp contains the following code:

Code: Select all

std::string voltage = root2["voltage"].asString();
int battery = 255;
if (voltage != "" && voltage != "3600") {
  battery = ((atoi(voltage.c_str()) - 2200) / 10);
}
...
if ((name == "Xiaomi Temperature/Humidity") || (name == "Xiaomi Aqara Weather")) {
  std::string temperature = root2["temperature"].asString();
  std::string humidity = root2["humidity"].asString();
  if (temperature != "") {
    m_XiaomiGateway->InsertUpdateTemperature(sid.c_str(), "Xiaomi Temperature", temp, battery);
  }
  if (humidity != "") {
    m_XiaomiGateway->InsertUpdateHumidity(sid.c_str(), "Xiaomi Humidity", hum, battery);
  }
  if (name == "Xiaomi Aqara Weather") {
    std::string pressure = root2["pressure"].asString();
    m_XiaomiGateway->InsertUpdatePressure(sid.c_str(), "Xiaomi Humidity", pres, battery);
  }
}
Note that the battery level may be 255 if it is not set or a value around -10..110

BTW, I don't see a source of the combined Temp/Hum sensor. XiaomiGateway.cpp never called SendTempHumSensor().

All possible 3 sensors (temp, hum and pressure) must have the same battery level.
But temp always has 100%, hum, temp/hum sometimes show the correct level.

I see few bugs:

Code: Select all

void CDomoticzHardwareBase::SendTempSensor(const int NodeID, const int BatteryLevel, const float temperature, const std::string &defaultname, const int RssiLevel /* =12 */)
{
  RBUF tsen;
  memset(&tsen, 0, sizeof(RBUF));
  tsen.TEMP.packetlength = sizeof(tsen.TEMP) - 1;
  tsen.TEMP.packettype = pTypeTEMP;
  ...
  tsen.TEMP.battery_level = BatteryLevel; // !!!
  ...
  sDecodeRXMessage(this, (const unsigned char *)&tsen.TEMP, defaultname.c_str(), BatteryLevel);
}
It looks like BatteryLevel passed to MainWorker::DecodeRXMessage is just lost.

The field RBUF.TEMP.battery_level is declared as BYTE : 4.
I have no idea how -10, 70, 110 or 255 may be correctly converted to 4 bits field.
It looks like this field expexts a value 0..9 which means 10, 20, ..100%.

Then in

Code: Select all

void MainWorker::decode_Temp(const int HwdID, const _eHardwareTypes HwdType, const tRBUF *pResponse, _tRxMessageProcessingResult & procResult)
{
   ...
	unsigned char BatteryLevel = 0;
	if ((pResponse->TEMP.battery_level & 0x0F) == 0)
		BatteryLevel = 0;
	else
		BatteryLevel = 100;
So the BatteryLevel is completelly lost at least for temp sensors.
I don't know how to correctly fix this bug. It is too deep and too much devices are affected.

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Friday 16 February 2018 0:53
by slydiman
Can someone of the main developers look at this?

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Saturday 24 February 2018 18:18
by slydiman
I see some serious bugs in the base classes of Domoticz.
Who is the right person to contact about it?
Endless discussions among users do not solve anything.
Where are the developers?
I can make minor fixes, but I will not edit the base classes.

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Tuesday 27 February 2018 12:16
by snuiter
Hi,

@slydiman did you try to reach out to gizmocuz, he might be able to point you in the right direction.

So if I got I correct the voltage levels for the temp/humid sensor is not propagated through to domoticz? I have voltage devices for all the Xiaomi door sensors but not for the several temp/humid sensors I am using. Would like to have them.

Any advice

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Wednesday 14 March 2018 21:35
by snuiter
Any information / update on this as I don't have any temperature/humid sensor that is reporting a battery level. All other Xiaomi devices do report the battery level.

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Saturday 24 March 2018 18:00
by slydiman
I did not contact gizmocuz.
Domoticz is no longer interesting to me, at least for now, while Xiaomi Android app works well enough.
Domoticz is very draft, buggy and unstable. The code is very confusing.
Domoticz cameras do not support RTSP. Cameras do not work (do not refresh) in Domoticz Android app at all.
I have the long list of problems with Xiaomi devices...
But I don't see a reason to post it because I don't see any updates around bugs in the fundamental code.

@snuiter, feel free to contact gizmocuz or anyone who can fix the issue which I described above.

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Saturday 24 March 2018 18:59
by LouiS22
slydiman wrote: Saturday 24 March 2018 18:00 I did not contact gizmocuz.
Domoticz is no longer interesting to me, at least for now, while Xiaomi Android app works well enough.
Domoticz is very draft, buggy and unstable. The code is very confusing.
Domoticz cameras do not support RTSP. Cameras do not work (do not refresh) in Domoticz Android app at all.
I have the long list of problems with Xiaomi devices...
But I don't see a reason to post it because I don't see any updates around bugs in the fundamental code.

@snuiter, feel free to contact gizmocuz or anyone who can fix the issue which I described above.
and that was a very, very rude comment. Why not contribute and solve those problems?

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Sunday 25 March 2018 9:45
by slydiman
Note I have dropped my own home automation system SlyControl in 2005 http://slydiman.me/sce/plugins.htm
I have enough expireence developing software for various hardware.
I prefer to have a clean base code. Solve these problems means a lot of workarounds with a buggy core. It is a wrong way.

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Tuesday 27 March 2018 11:17
by Vomera
Hi!

I have also the Xiaomi Aqara Temperature Humidity Sensor since a few days. I added this to domoticz. Temp and hum are fine but it also shows the pressure. Strange thing it will be added to the utility tab and not in the weather tab.
The other thing is you cant adjust the sensor. It shows 1003 hpa but at our level its now 1012 hpa. Is there a way to adjust this like the temperature or humidity ?


Image

Image

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Wednesday 28 March 2018 13:50
by poostrom
Same here, but I'm more confused that it show's 1003 Bar instead of 1003 mBar.

Re: Xiaomi Aqara Temperature Humidity Sensor

Posted: Sunday 31 January 2021 14:09
by sincze
Anyone that can confirm this is now working correctly on current beta ???

Domoticz 2020.2 (build 12872)