SANdood / PurpleAirStation

PurpleAir Air Quality Station for SmartThings & Hubitat
13 stars 19 forks source link

error on temp var #2

Open spokrandt opened 5 years ago

spokrandt commented 5 years ago

2019-04-12 12:30:24.448 pm errorjava.lang.NullPointerException: Cannot get property 'temp_f' on null object on line 485 (purpleAirResponse)

I have no clue when it comes to groovy... os i thought i'd create an issue

this is on hubitat version 2.0.8.113

spokrandt commented 5 years ago

ok i tried,. is it better to check if they are null then a number?

def temperature 
if ( !isNull(response.results[0].temp_f) && !isNull(response.results[1].temp_f)  )

// if (response.results[0].temp_f?.isNumber() && response.results[1].temp_f?.isNumber()) temperature = roundIt(((response.results[0].temp_f.toBigDecimal() + response.results[1].temp_f.toBigDecimal()) / 2.0), 1)

sendEvent(name: 'temperature', value: temperature, unit: 'F')
sendEvent(name: 'temperatureDisplay', value: roundIt(temperature, 0), unit: 'F', displayed: false)
SANdood commented 5 years ago

I think the version 1.1.02 that I just posted should handle the situation better - please let me know (I am travelling, so my responses may be delayed).

SANdood commented 5 years ago

I added some additional handling for only a single reporting sensor as 1.1.02a