michaelahern / homebridge-airthings

A Homebridge plugin for Airthings air quality monitors via the Airthings Consumer API.
ISC License
38 stars 6 forks source link

Avoid homekit cast exception since null is not an expected temperature #26

Closed cgrazy closed 1 year ago

cgrazy commented 1 year ago

Apple homekit cannot handle null as temperature and throws an exception (seen in debug log). Therefore use 0 as default instead.

cgrazy commented 1 year ago

Would it be better just not to set this, if we don't have a value?

if(this.latestSamples.data.temp) 
  this.temperatureService.getCharacteristic(api.hap.Characteristic.CurrentTemperature).updateValue(
     this.latestSamples.data.temp
  );

sounds reasonable. Will check it as soon as possible.

cgrazy commented 1 year ago

works lika a charm so far. Thanks @davidjbradshaw for the review and the change suggestion