pschroeder89 / homebridge-levoit-humidifiers

Levoit Humidifiers Plugin for Apple HomeKit via Homebridge
Apache License 2.0
70 stars 9 forks source link

fix: Only return `undefined` when `result` is missing (not unconditionally) #29

Closed smockle closed 2 years ago

smockle commented 2 years ago

Currently, in updateInfo, the else case (empty return) is hit even when data?.result?.result exists (i.e. when device info was fetched successfully). I suspect this is not intended. This PR modifies the else condition so that it is not hit when data is fetched successfully.

I tracked this down after noticing the error below in my logs:

[homebridge-levoit-humidifiers] This plugin generated a warning from the characteristic 'Current Relative Humidity': characteristic value expected valid finite number and received "undefined" (undefined). See https://homebridge.io/w/JtMGR for more info.

This error was introduced in v1.7.1; it does not repro in v1.7.0. Specifically, the if/else conditions were modified in https://github.com/pschroeder89/homebridge-levoit-humidifiers/commit/2bfec876f23160730908644f369b35760a11bba2.

Aside: Although similar conditionals were added to setPower, the same error isn’t present there, because the happy path (success) is checked first in that function.

pschroeder89 commented 2 years ago

Thanks for this @smockle ! Looks good, will push now

pschroeder89 commented 2 years ago

1.7.2 is published with your fix