Smanar / Domoticz-deCONZ

deCONZ plugin for Domoticz (Zigbee application)
GNU General Public License v3.0
36 stars 27 forks source link

Missing sensor type: ZHAAirQuality ? #103

Closed grrrmml closed 2 years ago

grrrmml commented 3 years ago

Hello,

I just bought a Develco Air Quality Sensor AQSZB-110 (frient 20204000) and added it to deCONZ.

It is supported by deCONZ rest plugin (since 2020-11) and showing values, I assume relevant: "manufacturername":"Develco Products A/S","modelid":"AQSZB-110","state":{"airquality":"excellent","airqualityppb":0,"lastupdated":"2021-06-24T21:25:37.455"},"type":"ZHAAirQuality"

... but probably not yet for (phoscon and) the Domoticz plugin: deCONZ: (deCONZ) Unknow device type ZHAAirQuality

Is this a problem on Domoticz side, or could you add support for ZHAAirQuality?

for value interpretation, see: https://github.com/dresden-elektronik/deconz-rest-plugin/pull/4378

With best regards

Smanar commented 3 years ago

Hello, sure I can, will be fast. Can you just share the device json to know which one you have ? I think you have

"AirQuality" with a string value "AirQualityPpb" with a numeric value

So can use the domoticz native one, with the numeric value. Domoticz have his own "string convertion". Not sure if it s the same unit, will see with your JSON.

Edit: Have started something, can you try the beta branch ?

grrrmml commented 3 years ago

Hello, yeah thank you, that's a good start. It's now shown as Type "Air Quality" (subtype "Voltcraft CO-20"), and has the numeric value. Just the unit is "ppm" which is not correct for my sensor type (VOC), it should be "ppb" instead.

Do you know if there is a Domoticz Sensor with that unit, and is linking just done by the name? (The string convertion then is another story, as mentioned in https://github.com/dresden-elektronik/deconz-rest-plugin/pull/4378, whose mapping seems by far more realistic that the one in the manual from the vendor ^^).

I'm already happy so far because now I can observe the value History in Domoticz, the unit is more like fine tuning. :-) I already added what I thought to be the relevant JSON data, if there is missing something relevant ,please give some detail and I will try to provide it.

With best regards

Smanar commented 3 years ago

Ok so It seem

1 Parts per billion [ppb] = 0,001 Parts per million [ppm]

So yes I can make the convertion, but I have tried some fake values using

http://192.168.1.1:8080/json.htm?type=command&param=udevice&idx=150&nvalue=20&svalue=0

And the widget seem use the good value for excelent, bad and ect ....

20 = excelent 1000 = fair 2000 = bad

If I use the convertion, not sure it will be better, and don't know at all air quality sensor, but can be just a unit description error ? You don't know the minimum and maximum value you can have with your device ?

grrrmml commented 3 years ago

Hi, thanks for checking and trying out. I will observe the values and can probably give some more feedback in about a week. I believe I should open an issue for domoticz to add a new device type for this kind of sensor with unit ppq, because VOC measurement seems to be completely another story than with CO... So I think just converting the values is not suitable. Technical Specs for the device are here: https://www.develcoproducts.com/media/1674/aqszb-110-technical-manual-air-quality-sensor-04-08-20.pdf (I believe the values there are more correct than the one in the print manual. ^^)

With best regards

Smanar commented 3 years ago

The VOC sensor measures VOC’s in parts per billion with a resolution of 1 – 32 ppb. Range 0 to 60000 ppb

So It mean I need to divide by 1000, but you will have 0 to 60 ppm ....

From the doc tmp

From the domoticz code

            if (pMeter->airquality < 700)
                strcpy(szTmp, "Quality = Excellent");
            else if (pMeter->airquality < 900)
                strcpy(szTmp, "Quality = Good");
            else if (pMeter->airquality < 1100)
                strcpy(szTmp, "Quality = Fair");
            else if (pMeter->airquality < 1600)
                strcpy(szTmp, "Quality = Mediocre");
            else
                strcpy(szTmp, "Quality = Bad");

So you are right, it s realy not the same scale .... If I use this sensor the state displayed will be not the good one.

So yes I m seing 2 solutions :

As you want ?

grrrmml commented 3 years ago

Hi, I think it should be a custom sensor then, until Domoticz has an AirQualityPpb Sensor type. (You could maybe add it to stable branch, so that other people can also already use it.)

I would suggest I open an Issue there in the next days and drop you a note when it's done. (Best would be with configurable text representations for the values, if possible.)

With best regards, thanks for your help so far!

Smanar commented 3 years ago

Hello, try updating the beta (with "git pull") Then delete the previous sensor, and reload the plugin. It will be recreated with custom sensor.

grrrmml commented 3 years ago

Hi, the custom sensor does work and shows the values. As this is not really a Code Issue, I added a comment to an existing Domoticz Issue, which is about missing Z-Wave VOC SubSensor(s): https://github.com/domoticz/domoticz/issues/2591

I would evaluate further options depending on the reply.

With best regards

Smanar commented 3 years ago

Nice, if they add a new sensor type, I will add it too.

waltervl commented 2 years ago

For the air quality yoo could use an alert sensor type 243, subtype 22, https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s#Alert_sensor

For a reference: The OpenAQ plugin makes use of this alert sensor https://github.com/Xorfor/Domoticz-OpenAQ-Plugin

Smanar commented 2 years ago

Ha yes, if you want this one ? Can use the color, with 4 possible level for different step And use the test to display the value.

waltervl commented 2 years ago

Well I am not using your plugin but came by accident in this discussion and thought I would give you a hint :-). So I think @grrrmml should answer this question.

grrrmml commented 2 years ago

Hi @waltervl, thanks for joining the discussion, this is basically a very good hint, until there is (maybe) a VOC air quality sensor in domoticz in the future. I like it to have both a sensor with the absolute value, and another with the quality levels. That way it leaves the "interpretation" to the user - thank you very much.

In case someone else finds this discussion by accident, here is what to do: 1) have a dummy hardware device, to be able to easily create a virtual sensor 2) create a virtual sensor, type AlertSensor 3) create a dzVents device script under events, for the hardware sensor, and use following code in the execute function to convert the values of the hardware device to states of the alert sensor (in my case: idx 1401 / replace with your id):

if (device.changed) then

domoticz.log('Device ' .. device.name .. ' was changed to ' .. device.sValue, domoticz.LOG_INFO)

local alertSensor = domoticz.devices(1401)

if (device.nValue <= 300) then

    alertSensor.updateAlertSensor(domoticz.ALERTLEVEL_GREEN, 'excellent')

elseif (device.nValue <= 1000) then

    alertSensor.updateAlertSensor(domoticz.ALERTLEVEL_GREY, 'good')

elseif (device.nValue <= 3000) then

     alertSensor.updateAlertSensor(domoticz.ALERTLEVEL_YELLOW, 'moderate')

elseif (device.nValue <= 10000) then

     alertSensor.updateAlertSensor(domoticz.ALERTLEVEL_ORANGE, 'poor')

elseif (device.nValue > 10000 ) then

     alertSensor.updateAlertSensor(domoticz.ALERTLEVEL_RED, 'unhealty')

end

end

Smanar commented 2 years ago

@grrrmml it s as you prefer, if you prefer the alert widget by defaut insteaf of the custom sensor, we can use it by defaut ?

grrrmml commented 2 years ago

Hello, the alert widget is okay to show the quality as text, but i prefer the custom sensor, to have a graphical history. I'll get back to you if I see another (better) alternative, thank you! :-)

Regards, grrrmml