Skip to content

Commit 4b47ece

Browse files
committed
[BleBox] Add support for airSensor and use the newest api for shutterBox
1 parent 17069c4 commit 4b47ece

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

hardware/BleBox.cpp

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct STR_DEVICE {
2020
std::string api_state;
2121
};
2222

23-
#define TOT_DEVICE_TYPES 7
23+
#define TOT_DEVICE_TYPES 8
2424

2525
const STR_DEVICE DevicesType[TOT_DEVICE_TYPES] =
2626
{
@@ -30,7 +30,8 @@ const STR_DEVICE DevicesType[TOT_DEVICE_TYPES] =
3030
{ 3, "wLightBox", "Light Box", pTypeColorSwitch, sTypeColor_RGB_W, STYPE_Dimmer, "rgbw" },
3131
{ 4, "gateBox", "Gate Box", pTypeGeneral, sTypePercentage, 0, "gate" },
3232
{ 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" },
3435
};
3536

3637
BleBox::BleBox(const int id, const int pollIntervalsec)
@@ -123,6 +124,11 @@ void BleBox::GetDevicesState()
123124
}
124125
case 1:
125126
{
127+
if (DoesNodeExists(root, "shutter") == false)
128+
break;
129+
130+
root = root["shutter"];
131+
126132
if (DoesNodeExists(root, "state") == false)
127133
break;
128134

@@ -207,6 +213,30 @@ void BleBox::GetDevicesState()
207213

208214
break;
209215
}
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+
}
210240
}
211241
SetHeartbeatReceived();
212242
}

0 commit comments

Comments
 (0)