@@ -279,20 +279,20 @@ private boolean updateRelayStatus(int id, ShellySettingsStatus status, @Nullable
279279 if (rs .output != null ) {
280280 sr .ison = rstatus .ison = getBool (rs .output );
281281 }
282- if (getDouble (rs .timerStartetAt ) > 0 ) {
283- int duration = (int ) (now () - rs .timerStartetAt );
284- sr . timerRemaining = duration ;
282+ if (rs . timerStartetAt != null && getDouble (rs .timerStartetAt ) > 0 ) {
283+ sr . timerRemaining = (int ) (now () - getDouble ( rs .timerStartetAt ) );
284+ ;
285285 }
286- if (rs .temperature != null ) {
286+ if (rs .temperature != null && rs . temperature . tC != null ) {
287287 if (status .tmp == null ) {
288288 status .tmp = new ShellySensorTmp ();
289289 }
290290 status .tmp .isValid = true ;
291291 status .tmp .tC = rs .temperature .tC ;
292292 status .tmp .tF = rs .temperature .tF ;
293293 status .tmp .units = "C" ;
294- sr .temperature = getDouble ( rs .temperature .tC ) ;
295- if (status .temperature == null || getDouble ( rs .temperature .tC ) > status .temperature ) {
294+ sr .temperature = rs .temperature .tC ;
295+ if (status .temperature == null || rs .temperature .tC > status .temperature ) {
296296 status .temperature = sr .temperature ;
297297 }
298298 }
@@ -372,7 +372,7 @@ private boolean updateBreakerStatus(int id, ShellySettingsStatus status, @Nullab
372372 if (bs .output != null ) {
373373 sr .ison = rstatus .ison = getBool (bs .output );
374374 }
375- if (bs .temperature != null ) {
375+ if (bs .temperature != null && bs . temperature . tC != null ) {
376376 if (status .tmp == null ) {
377377 status .tmp = new ShellySensorTmp ();
378378 }
@@ -728,7 +728,7 @@ private boolean updateDimmerStatus(int id, ShellySettingsStatus status, @Nullabl
728728 value .id = id ;
729729 }
730730
731- ShellyShortLightStatus ds = status .dimmers .get (0 );
731+ ShellyShortLightStatus ds = status .dimmers .get (value . id );
732732 if (value .brightness != null ) {
733733 ds .brightness = value .brightness .intValue ();
734734 }
@@ -806,9 +806,9 @@ private void updateAddonStatus(ShellySettingsStatus status, @Nullable Shelly2Dev
806806 private @ Nullable ShellyShortTemp updateExtTempSensor (@ Nullable Shelly2DeviceStatusTempId value ) {
807807 if (value != null ) {
808808 ShellyShortTemp temp = new ShellyShortTemp ();
809- temp .hwID = value .id . toString ();
810- temp .tC = value .tC ;
811- temp .tF = value .tF ;
809+ temp .hwID = value .id != null ? value . id . toString () : "999" ;
810+ temp .tC = getDouble ( value .tC ) ;
811+ temp .tF = getDouble ( value .tF ) ;
812812 return temp ;
813813 }
814814 return null ;
@@ -833,8 +833,8 @@ protected void updateTemperatureStatus(ShellyStatusSensor sdata, @Nullable Shell
833833 }
834834 sdata .tmp .isValid = true ;
835835 sdata .tmp .units = SHELLY_TEMP_CELSIUS ;
836- sdata .tmp .tC = value .tC ;
837- sdata .tmp .tF = value .tF ;
836+ sdata .tmp .tC = getDouble ( value .tC ) ;
837+ sdata .tmp .tF = getDouble ( value .tF ) ;
838838 }
839839
840840 protected void updateIlluminanceStatus (ShellyStatusSensor sdata , @ Nullable Shelly2DeviceStatusIlluminance value ) {
@@ -845,8 +845,8 @@ protected void updateIlluminanceStatus(ShellyStatusSensor sdata, @Nullable Shell
845845 sdata .lux = new ShellySensorLux ();
846846 }
847847 sdata .lux .isValid = value .lux != null ;
848- sdata .lux .value = value .lux ;
849- sdata .lux .illumination = value .illumination ;
848+ sdata .lux .value = getDouble ( value .lux ) ;
849+ sdata .lux .illumination = getString ( value .illumination ) ;
850850 }
851851
852852 protected void updateSmokeStatus (ShellyStatusSensor sdata , @ Nullable Shelly2DeviceStatusSmoke value ) {
@@ -866,10 +866,10 @@ protected void updateBatteryStatus(ShellyStatusSensor sdata, @Nullable Shelly2De
866866 }
867867
868868 if (value .battery != null ) {
869- sdata .bat .voltage = value .battery .volt ;
870- sdata .bat .value = value .battery .percent ;
869+ sdata .bat .voltage = getDouble ( value .battery .volt ) ;
870+ sdata .bat .value = getDouble ( value .battery .percent ) ;
871871 }
872- if (value .external != null ) {
872+ if (value .external != null && value . external . present != null ) {
873873 sdata .charger = value .external .present ;
874874 }
875875 }
@@ -966,14 +966,16 @@ protected Shelly2RpcBaseMessage buildRequest(String method, @Nullable Object par
966966 }
967967
968968 protected String mapValue (Map <String , String > map , @ Nullable String key ) {
969- String safeKey = getString (key );
970- if (safeKey .isEmpty () || !map .containsKey (safeKey )) {
971- logger .warn ("{}: Unknown API value '{}' (map data={}), please create an issue on GitHub" , thingName ,
972- safeKey , map );
969+ if (key == null || key .isEmpty ()) {
973970 return "" ;
974971 }
975- String value = getString (map .get (safeKey ));
976- logger .trace ("{}: API value '{}' was mapped to '{}'" , thingName , safeKey , value );
972+ if (!map .containsKey (key )) {
973+ logger .warn ("{}: Unknown API value '{}' (map data={}), please create an issue on GitHub" , thingName , key ,
974+ map );
975+ return "" ;
976+ }
977+ String value = getString (map .get (key ));
978+ logger .trace ("{}: API value '{}' was mapped to '{}'" , thingName , key , value );
977979 return value ;
978980 }
979981
0 commit comments