@@ -20,7 +20,7 @@ struct STR_DEVICE {
20
20
std::string api_state;
21
21
};
22
22
23
- #define TOT_DEVICE_TYPES 7
23
+ #define TOT_DEVICE_TYPES 8
24
24
25
25
const STR_DEVICE DevicesType[TOT_DEVICE_TYPES] =
26
26
{
@@ -30,7 +30,8 @@ const STR_DEVICE DevicesType[TOT_DEVICE_TYPES] =
30
30
{ 3 , " wLightBox" , " Light Box" , pTypeColorSwitch, sTypeColor_RGB_W , STYPE_Dimmer, " rgbw" },
31
31
{ 4 , " gateBox" , " Gate Box" , pTypeGeneral, sTypePercentage , 0 , " gate" },
32
32
{ 5 , " dimmerBox" , " Dimmer Box" , pTypeLighting2, sTypeAC , STYPE_Dimmer, " dimmer" },
33
- { 6 , " switchBoxD" , " Switch Box D" , pTypeLighting2, sTypeAC , STYPE_OnOff, " relay" }
33
+ { 6 , " switchBoxD" , " Switch Box D" , pTypeLighting2, sTypeAC , STYPE_OnOff, " relay" },
34
+ { 7 , " airSensor" , " Air Sensor" , pTypeAirQuality, sTypeVoltcraft , 0 , " air" },
34
35
};
35
36
36
37
BleBox::BleBox (const int id, const int pollIntervalsec)
@@ -123,6 +124,11 @@ void BleBox::GetDevicesState()
123
124
}
124
125
case 1 :
125
126
{
127
+ if (DoesNodeExists (root, " shutter" ) == false )
128
+ break ;
129
+
130
+ root = root[" shutter" ];
131
+
126
132
if (DoesNodeExists (root, " state" ) == false )
127
133
break ;
128
134
@@ -207,6 +213,30 @@ void BleBox::GetDevicesState()
207
213
208
214
break ;
209
215
}
216
+ case 7 :
217
+ {
218
+ if (DoesNodeExists (root, " air" ) == false )
219
+ break ;
220
+
221
+ root = root[" air" ];
222
+
223
+ if ((DoesNodeExists (root, " sensors" ) == false ) || (!root[" sensors" ].isArray ()))
224
+ break ;
225
+
226
+ Json::Value sensors = root[" sensors" ];
227
+ Json::ArrayIndex count = sensors.size ();
228
+ for (Json::ArrayIndex index = 0 ; index < count; index++)
229
+ {
230
+ Json::Value sensor = sensors[index];
231
+ if ((DoesNodeExists (sensor, " type" ) == false ) || (DoesNodeExists (sensor, " value" ) == false ))
232
+ break ;
233
+ uint8_t value = (uint8_t )sensor[" value" ].asInt ();
234
+ std::string type = sensor[" type" ].asString ();
235
+ SendAirQualitySensor (IP, index + 1 , 255 , value, type);
236
+ }
237
+
238
+ break ;
239
+ }
210
240
}
211
241
SetHeartbeatReceived ();
212
242
}
0 commit comments