jasonsnell / PurpleAir-AQI-Scriptable-Widget

Generate Scriptable app widget to query PurpleAir sensor and display local AQI.
The Unlicense
168 stars 38 forks source link

Fallback to `stats.pm2.5` field when `stats.pm2.5_cf_1` is undefined #39

Closed eramdam closed 1 year ago

eramdam commented 1 year ago

When trying to set up the widget for myself, I noticed that the pm2.5_cf_1 field wasn't defined, resulting in the widget not displaying any value.

CleanShot 2023-09-21 at 01 24 39@2x

I don't know if json.sensor.stats["pm2.5_cf_1"] is a typo and should be json.sensor["pm2.5_cf_1"] instead or if pm2.5_cf_1 used to be available on the stats object but in any case, this PR fixed the issue for me so feel free to merge it if that's The Right Way™️ to do it 😁

bennywij commented 1 year ago

Hi @eramdam -- I noticed too Purple Air's API now puts "pm2.5_cf_1" at the top level and not in stats. I'll upvote your PR.

eramdam commented 1 year ago

Hi @eramdam -- I noticed too Purple Air's API now puts "pm2.5_cf_1" at the top level and not in stats. I'll upvote your PR.

I'll close this PR because yours is probably the better way to do it 😁