@@ -386,7 +386,7 @@ int CNetatmo::GetBatteryLevel(const std::string &ModuleType, const int battery_p
386
386
return batValue;
387
387
}
388
388
389
- bool CNetatmo::ParseDashboard (const Json::Value &root, const int DevIdx, const int ID, const std::string &name, const std::string &ModuleType, const int battery_percent)
389
+ bool CNetatmo::ParseDashboard (const Json::Value &root, const int DevIdx, const int ID, const std::string &name, const std::string &ModuleType, const int battery_percent, const int rssiLevel )
390
390
{
391
391
bool bHaveTemp = false ;
392
392
bool bHaveHum = false ;
@@ -508,15 +508,15 @@ bool CNetatmo::ParseDashboard(const Json::Value &root, const int DevIdx, const i
508
508
else if (pressure >= 1029 )
509
509
nforecast = wsbaroforcast_sunny;
510
510
}
511
- SendTempHumBaroSensorFloat (ID, batValue, temp, hum, baro, nforecast, name);
511
+ SendTempHumBaroSensorFloat (ID, batValue, temp, hum, baro, nforecast, name, rssiLevel );
512
512
}
513
513
else if (bHaveTemp && bHaveHum)
514
514
{
515
- SendTempHumSensor (ID, batValue, temp, hum, name);
515
+ SendTempHumSensor (ID, batValue, temp, hum, name, rssiLevel );
516
516
}
517
517
else if (bHaveTemp)
518
518
{
519
- SendTempSensor (ID, batValue, temp, name);
519
+ SendTempSensor (ID, batValue, temp, name, rssiLevel );
520
520
}
521
521
522
522
if (bHaveSetpoint)
@@ -551,7 +551,7 @@ bool CNetatmo::ParseDashboard(const Json::Value &root, const int DevIdx, const i
551
551
m_RainOffset[ID] += m_OldRainCounter[ID];
552
552
}
553
553
m_OldRainCounter[ID] = rain;
554
- SendRainSensor (ID, batValue, m_RainOffset[ID] + m_OldRainCounter[ID], name);
554
+ SendRainSensor (ID, batValue, m_RainOffset[ID] + m_OldRainCounter[ID], name, rssiLevel );
555
555
}
556
556
557
557
if (bHaveCO2)
@@ -566,7 +566,7 @@ bool CNetatmo::ParseDashboard(const Json::Value &root, const int DevIdx, const i
566
566
567
567
if (bHaveWind)
568
568
{
569
- SendWind (ID, batValue, wind_angle, wind_strength, wind_gust, 0 , 0 , false , name);
569
+ SendWind (ID, batValue, wind_angle, wind_strength, wind_gust, 0 , 0 , false , name, rssiLevel );
570
570
}
571
571
return true ;
572
572
}
@@ -809,18 +809,27 @@ bool CNetatmo::ParseNetatmoGetResponse(const std::string &sResult, const bool bI
809
809
if (mname.empty ())
810
810
mname = nDevice.ModuleName ;
811
811
int mbattery_percent = 0 ;
812
- if (module [" battery_percent" ].empty () == false )
812
+ if (! module [" battery_percent" ].empty ())
813
813
{
814
814
mbattery_percent = module [" battery_percent" ].asInt ();
815
815
}
816
+ int mrf_status = 0 ;
817
+ if (!module [" rf_status" ].empty ())
818
+ {
819
+ // 90=low, 60=highest
820
+ mrf_status = ( 90 - module [" rf_status" ].asInt ())/3 ;
821
+ if (mrf_status > 10 ){
822
+ mrf_status = 10 ;
823
+ }
824
+ }
816
825
int crcId = Crc32 (0 , (const unsigned char *)mid.c_str (), mid.length ());
817
826
if (!module [" dashboard_data" ].empty ())
818
827
{
819
- ParseDashboard (module [" dashboard_data" ], iDevIndex, crcId, mname, mtype, mbattery_percent);
828
+ ParseDashboard (module [" dashboard_data" ], iDevIndex, crcId, mname, mtype, mbattery_percent, mrf_status );
820
829
}
821
830
else if (!module [" measured" ].empty ())
822
831
{
823
- ParseDashboard (module [" measured" ], iDevIndex, crcId, mname, mtype, mbattery_percent);
832
+ ParseDashboard (module [" measured" ], iDevIndex, crcId, mname, mtype, mbattery_percent, mrf_status );
824
833
if (mtype == " NATherm1" )
825
834
{
826
835
m_thermostatDeviceID[iDevIndex] = nDevice.ID ;
@@ -838,7 +847,7 @@ bool CNetatmo::ParseNetatmoGetResponse(const std::string &sResult, const bool bI
838
847
// Check if setpoint was just set, and if yes, overrule the previous setpoint
839
848
if (!module [" setpoint" ][" setpoint_temp" ].empty ())
840
849
{
841
- ParseDashboard (module [" setpoint" ], iDevIndex, crcId, mname, mtype, mbattery_percent);
850
+ ParseDashboard (module [" setpoint" ], iDevIndex, crcId, mname, mtype, mbattery_percent, mrf_status );
842
851
}
843
852
}
844
853
}
@@ -852,14 +861,23 @@ bool CNetatmo::ParseNetatmoGetResponse(const std::string &sResult, const bool bI
852
861
_netatmo_devices.push_back (nDevice);
853
862
854
863
int battery_percent = 0 ;
855
- if (device[" battery_percent" ].empty () == false )
864
+ if (! device[" battery_percent" ].empty ())
856
865
{
857
866
battery_percent = device[" battery_percent" ].asInt ();
858
867
}
868
+ int wifi_status = 0 ;
869
+ if (!device[" wifi_status" ].empty ())
870
+ {
871
+ // 86=bad, 56=good
872
+ wifi_status = ( 86 - device[" wifi_status" ].asInt ())/3 ;
873
+ if (wifi_status > 10 ){
874
+ wifi_status = 10 ;
875
+ }
876
+ }
859
877
int crcId = Crc32 (0 , (const unsigned char *)id.c_str (), id.length ());
860
878
if (!device[" dashboard_data" ].empty ())
861
879
{
862
- ParseDashboard (device[" dashboard_data" ], iDevIndex, crcId, name, type, battery_percent);
880
+ ParseDashboard (device[" dashboard_data" ], iDevIndex, crcId, name, type, battery_percent, wifi_status );
863
881
}
864
882
}
865
883
iDevIndex++;
@@ -931,6 +949,15 @@ bool CNetatmo::ParseNetatmoGetResponse(const std::string &sResult, const bool bI
931
949
{
932
950
battery_percent = module [" battery_percent" ].asInt ();
933
951
}
952
+ int rf_status = 0 ;
953
+ if (!module [" rf_status" ].empty ())
954
+ {
955
+ // 90=low, 60=highest
956
+ rf_status = ( 90 - module [" rf_status" ].asInt ())/3 ;
957
+ if (rf_status > 10 ){
958
+ rf_status = 10 ;
959
+ }
960
+ }
934
961
stdreplace (name, " '" , " " );
935
962
936
963
// std::set<std::string> dataTypes;
@@ -941,7 +968,7 @@ bool CNetatmo::ParseNetatmoGetResponse(const std::string &sResult, const bool bI
941
968
int crcId = Crc32 (0 , (const unsigned char *)id.c_str (), id.length ());
942
969
if (!module [" dashboard_data" ].empty ())
943
970
{
944
- ParseDashboard (module [" dashboard_data" ], iDevIndex, crcId, name, type, battery_percent);
971
+ ParseDashboard (module [" dashboard_data" ], iDevIndex, crcId, name, type, battery_percent, rf_status );
945
972
}
946
973
}
947
974
return (!_netatmo_devices.empty ());
0 commit comments