Incorrect devices created after adding MCOHome A8-9 air quality sensor

For devices supporting the Auto Discovery feature. Like ZWaveJS2MQTT, Zigbee2MQTT.

Moderator: leecollings

Post Reply
manutremo
Posts: 69
Joined: Saturday 19 November 2016 17:02
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Incorrect devices created after adding MCOHome A8-9 air quality sensor

Post by manutremo »

Hi, I recently added the referenced air quality sensor to my domoticz install. Most of the sensors came up correctly, but I have some issues of different criticality levels that I've tried to solve myself with no success.

The setup is Domoticz 2024.7 (build 16360), with Zigbee MQTT Autodiscovery plugin, with Zwave-JS-IU 9.27.8 and Zwaqve-JS 14.3.7.

The MCOHome A8-9 sensor has the latest firmware 6.4.

1. Co2 sensor is reported in Zwave-JS-UI as zwave sensortype 17 and scale 0. According to the documentation in the Zwave Alliance, that corresponds to a Co2 sensor with measurement in ppm, which is correct. However the device created in Domoticz is an Air Quality type, Voc type. However, this diesn't seem to have any impact since the ppm values (in the 100's values) appear correctly.

2. Similarly, the PM2.5 zwave device is sensortype 35, scale 1, which is a PM2.5 device with measurement in µg/m3. However domoticz creates a Custom sensor. Once created it works well.

3. The Voc sensor is reported in Zwave-JS-UI as sensortype 39, scale 1, which corresponds to a device with sensortype VOC level and scale in ppm. The device created by domoticz looks correct, however the Voc values tend to be in the 100's ppb, so 0.something ppm. This problem is that this device doesn't seem to support decimal places, so it always shows 0ppm. I even tried to create a virtual device and use a dzvents script to multiply the value in the original by 1000 to get the correct value, but it always report 0.

Issues 1 and 2 are not critical since the correct values are shown, but issue 3 is something I'd really like to see fixed since, with dangerous Voc levels being around 500ppb = 0.5 ppm, it is important to be able to see the decimal places.

My guess is that maybe domoticz doesn't support all the possible devices in the zwave specification, so tries to use custom sensors to mimc them. The most critical issue is obviously number 2. I've tried to look into the domoticz code to find where devices are created and zwave sensor types are being mapped to the available devices types, with no success. So I decided to post the question here in hope that someone can help me find out and probably try to controbute an update to the code.

Thanks in advance.
manutremo
Posts: 69
Joined: Saturday 19 November 2016 17:02
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Incorrect devices created after adding MCOHome A8-9 air quality sensor

Post by manutremo »

Ok I answer myself.

I was ssuming that domoticz may have some kind of mapping table to translate the sensortype and scale vales coming from the Zwave driver. However apparently instead of using those values, domoticz tries to guess which device type fits better using the units of measurement. This can be seen in function GuessSensorTypeValue in MQTTAutoDiscover.cpp. This doesn't look like like the most direct approach, but I guess there was a good reason for choosing it.

So for case 1 and 3 in my original note, where both CO2 and Voc are being reported in ppm, the code that gets executed is:

if (szUnit == "ppm")
{
devType = pTypeAirQuality;
subType = sTypeVoc;
nValue = atoi(pSensor->last_value.c_str());
}

which explains not just why both devices are created with subtye Voc, but also why the values shown don't support decimal places (the atoi function). This looks like a sensible guess given that ppm values rarely contain decimals, but in the specifc case of Voc the decimal places are critical.

Actaually, looking into DomoticzHadware.h, it looks like Voc is the only allowed subtype for airquality devices - which leads to an interesting inconsistency with dzVents, which uses the Co2 string in the functions related to air quality sensors.

Unfortunately this doesn't look like something that can be fixed easily by modifying some config file, but is part of the program itself. It would probably be possible to expand this guess approach to more finely fit the device created by domoticz to the specific measurement, for example, defining an integer measurement for CO2 but a float for VOC.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests