Add indoor air quality interface and catch invalid VOC measurement value
This commit is contained in:
parent
1e197fb4ce
commit
492b59e9d1
@ -368,7 +368,13 @@ void IntegrationPluginZigbeeDevelco::setupThing(ThingSetupInfo *info)
|
||||
bool valueOk = false;
|
||||
quint16 value = measuredValueAttribute.dataType().toUInt16(&valueOk);
|
||||
if (valueOk) {
|
||||
thing->setStateValue(airQualitySensorVocStateTypeId, value);
|
||||
if (value == 0xFFFF) {
|
||||
qCWarning(dcZigbeeDevelco()) << "Received invalid VOC measurment. The sensor is not ready yet.";
|
||||
} else {
|
||||
qCDebug(dcZigbeeDevelco()) << thing << "VOC changed" << value << "ppm";
|
||||
thing->setStateValue(airQualitySensorVocStateTypeId, value);
|
||||
updateIndoorAirQuality(thing, value);
|
||||
}
|
||||
} else {
|
||||
qCWarning(dcZigbeeDevelco()) << "Failed to convert VOC measurment value" << measuredValueAttribute;
|
||||
}
|
||||
@ -379,8 +385,13 @@ void IntegrationPluginZigbeeDevelco::setupThing(ThingSetupInfo *info)
|
||||
bool valueOk = false;
|
||||
quint16 value = attribute.dataType().toUInt16(&valueOk);
|
||||
if (valueOk) {
|
||||
qCDebug(dcZigbeeDevelco()) << thing << "VOC changed" << value << "ppm";
|
||||
thing->setStateValue(airQualitySensorVocStateTypeId, value);
|
||||
if (value == 0xFFFF) {
|
||||
qCWarning(dcZigbeeDevelco()) << "Received invalid VOC measurment. The sensor is not ready yet.";
|
||||
} else {
|
||||
qCDebug(dcZigbeeDevelco()) << thing << "VOC changed" << value << "ppm";
|
||||
thing->setStateValue(airQualitySensorVocStateTypeId, value);
|
||||
updateIndoorAirQuality(thing, value);
|
||||
}
|
||||
} else {
|
||||
qCWarning(dcZigbeeDevelco()) << "Failed to convert VOC measurment value" << attribute;
|
||||
}
|
||||
@ -830,6 +841,21 @@ void IntegrationPluginZigbeeDevelco::configureVocReporting(ZigbeeNode *node, Zig
|
||||
});
|
||||
}
|
||||
|
||||
void IntegrationPluginZigbeeDevelco::updateIndoorAirQuality(Thing *thing, uint voc)
|
||||
{
|
||||
if (voc <= 65) {
|
||||
thing->setStateValue(airQualitySensorIndoorAirQualityStateTypeId, "Excellent");
|
||||
} else if (voc <= 220) {
|
||||
thing->setStateValue(airQualitySensorIndoorAirQualityStateTypeId, "Good");
|
||||
} else if (voc <= 660) {
|
||||
thing->setStateValue(airQualitySensorIndoorAirQualityStateTypeId, "Moderate");
|
||||
} else if (voc <= 2200) {
|
||||
thing->setStateValue(airQualitySensorIndoorAirQualityStateTypeId, "Poor");
|
||||
} else {
|
||||
thing->setStateValue(airQualitySensorIndoorAirQualityStateTypeId, "Unhealthy");
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginZigbeeDevelco::readDevelcoFirmwareVersion(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint)
|
||||
{
|
||||
// Read manufacturer specific basic cluster attribute 0x8000
|
||||
|
||||
@ -119,6 +119,7 @@ private:
|
||||
void configureHumidityReporting(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
||||
void configureBattryVoltageReporting(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
||||
void configureVocReporting(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
||||
void updateIndoorAirQuality(Thing *thing, uint voc);
|
||||
|
||||
void readDevelcoFirmwareVersion(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
||||
void readOnOffPowerAttribute(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
||||
|
||||
@ -153,7 +153,7 @@
|
||||
"name": "airQualitySensor",
|
||||
"displayName": "Air qualiy sensor",
|
||||
"createMethods": ["auto"],
|
||||
"interfaces": ["temperaturesensor", "humiditysensor", "battery", "wirelessconnectable"],
|
||||
"interfaces": ["indoorairquality", "temperaturesensor", "humiditysensor", "battery", "wirelessconnectable"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "dbad9e63-1adc-45ef-8bfc-4947060f19f4",
|
||||
@ -228,6 +228,21 @@
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "8396ec7e-54d4-452f-9558-c366e0904b2f",
|
||||
"name": "indoorAirQuality",
|
||||
"displayName": "Air quality",
|
||||
"displayNameEvent": "Air quality changed",
|
||||
"type": "QString",
|
||||
"defaultValue": "Good",
|
||||
"possibleValues": [
|
||||
"Excellent",
|
||||
"Good",
|
||||
"Moderate",
|
||||
"Poor",
|
||||
"Unhealthy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1ba14107-4241-46d0-b65f-eb6e8c6f8e08",
|
||||
"name": "voc",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user