Xiaomi Aqara Temperature Humidity Sensor

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

Moderator: leecollings

Post Reply
serak
Posts: 7
Joined: Friday 15 December 2017 11:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Xiaomi Aqara Temperature Humidity Sensor

Post 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?
slydiman
Posts: 9
Joined: Sunday 04 February 2018 13:30
Target OS: Windows
Domoticz version:
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post 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.
slydiman
Posts: 9
Joined: Sunday 04 February 2018 13:30
Target OS: Windows
Domoticz version:
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post by slydiman »

Can someone of the main developers look at this?
slydiman
Posts: 9
Joined: Sunday 04 February 2018 13:30
Target OS: Windows
Domoticz version:
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post 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.
snuiter
Posts: 67
Joined: Saturday 17 June 2017 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post 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
snuiter
Posts: 67
Joined: Saturday 17 June 2017 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post 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.
slydiman
Posts: 9
Joined: Sunday 04 February 2018 13:30
Target OS: Windows
Domoticz version:
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post 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.
User avatar
LouiS22
Posts: 433
Joined: Friday 27 February 2015 13:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post 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?
slydiman
Posts: 9
Joined: Sunday 04 February 2018 13:30
Target OS: Windows
Domoticz version:
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post 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.
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post 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
poostrom
Posts: 16
Joined: Tuesday 26 January 2016 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Gorinchem - Netherlands
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post by poostrom »

Same here, but I'm more confused that it show's 1003 Bar instead of 1003 mBar.
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Xiaomi Aqara Temperature Humidity Sensor

Post by sincze »

Anyone that can confirm this is now working correctly on current beta ???

Domoticz 2020.2 (build 12872)
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests