DMBlakeley/homebridge-awair2

Awair2 Element not getting values

dewey opened this issue · 5 comments

dewey commented

Hey,

thanks for the plugin! I stumbled into this potential issue when running it and I'm not sure where to proceed with the debugging. Would be great if someone could point me into the right direction. I'll happily gather additional information if needed.

Thanks,

Philipp

Describe The Bug:
I'm using homebridge-awair2 v5.6.4 on a just installed version of Homebridge (v1.2.5). I connected my Awair Element (awair-element), used the Developer Token from the Awair iOS app and I see the devices in the Home.app. Unfortunately the values are all zero values. I can't spot any errors in the logs but one suspicious line could be that:

[1/21/2021, 7:43:02 PM] [Awair2] [70886B143462] updateAirData: []

Expected behavior:
The value showing up in the accessory view (http://host:8581/accessories) or the Home.app.

Logs:

[1/21/2021, 7:42:49 PM] Got SIGTERM, shutting down Homebridge...
[1/21/2021, 7:42:54 PM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[1/21/2021, 7:42:59 PM] [HB Supervisor] Restarting Homebridge...
[1/21/2021, 7:42:59 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -P /homebridge/node_modules
[1/21/2021, 7:42:59 PM] [HB Supervisor] Started Homebridge v1.2.5 with PID: 1293
[1/21/2021, 7:43:00 PM] Loaded config.json with 0 accessories and 3 platforms.
[1/21/2021, 7:43:00 PM] ---
[1/21/2021, 7:43:00 PM] Loaded plugin: homebridge-awair2@5.6.4
[1/21/2021, 7:43:00 PM] Registering platform 'homebridge-awair2.Awair2'
[1/21/2021, 7:43:00 PM] ---
[1/21/2021, 7:43:00 PM] Loaded plugin: homebridge-dummy@0.5.0
[1/21/2021, 7:43:00 PM] Registering accessory 'homebridge-dummy.DummySwitch'
[1/21/2021, 7:43:00 PM] ---
[1/21/2021, 7:43:00 PM] Loaded plugin: homebridge-webos-tv@2.0.8
[1/21/2021, 7:43:00 PM] Registering platform 'homebridge-webos-tv.webostv'
[1/21/2021, 7:43:00 PM] ---
[1/21/2021, 7:43:00 PM] Loaded plugin: homebridge-config-ui-x@4.36.0
[1/21/2021, 7:43:00 PM] Registering platform 'homebridge-config-ui-x.config'
[1/21/2021, 7:43:00 PM] ---
[1/21/2021, 7:43:00 PM] Loading 3 platforms...
[1/21/2021, 7:43:00 PM] [Config] Initializing config platform...
[1/21/2021, 7:43:00 PM] [Config] Running in Service Mode
[1/21/2021, 7:43:00 PM] [Awair2] Initializing Awair2 platform...
[1/21/2021, 7:43:00 PM] [webostv] Initializing webostv platform...
[1/21/2021, 7:43:00 PM] [Awair2] Loading accessory from cache: Awair
[1/21/2021, 7:43:00 PM] [webostv] Init - initializing devices
[1/21/2021, 7:43:00 PM] [webostv] [TV] Init - got TV configuration, initializing device with name: TV
[1/21/2021, 7:43:01 PM] Homebridge v1.2.5 is running on port 51579.
[1/21/2021, 7:43:01 PM] [Awair2] userInfo: {"usages":[{"scope":"USER_DEVICE_LIST","usage":1},{"scope":"USER_INFO","usage":2}],"tier":"Hobbyist","email":"redacted","permissions":[{"scope":"FIFTEEN_MIN","quota":100},{"scope":"FIVE_MIN","quota":300},{"scope":"RAW","quota":500},{"scope":"LATEST","quota":300},{"scope":"PUT_PREFERENCE","quota":300},{"scope":"PUT_DISPLAY_MODE","quota":300},{"scope":"PUT_LED_MODE","quota":300},{"scope":"PUT_KNOCKING_MODE","quota":300},{"scope":"PUT_TIMEZONE","quota":300},{"scope":"PUT_DEVICE_NAME","quota":300},{"scope":"PUT_LOCATION","quota":300},{"scope":"PUT_ROOM_TYPE","quota":300},{"scope":"PUT_SPACE_TYPE","quota":300},{"scope":"GET_DISPLAY_MODE","quota":300},{"scope":"GET_LED_MODE","quota":300},{"scope":"USER_DEVICE_LIST","quota":2147483647},{"scope":"USER_INFO","quota":2147483647},{"scope":"GET_KNOCKING_MODE","quota":300},{"scope":"GET_POWER_STATUS","quota":300},{"scope":"GET_TIMEZONE","quota":300}],"sex":"UNKNOWN","lastName":"redacted","firstName":"redacted","id":"88924"}
[1/21/2021, 7:43:01 PM] [Awair2] getAwairDevices: number discovered: 1
[1/21/2021, 7:43:01 PM] [Awair2] getAwairDevices: discovered device: [0] {"name":"Awair","macAddress":"redacted","latitude": redacted,"preference":"GENERAL","timezone":"Europe/Berlin","roomType":"BEDROOM","deviceType":"awair-element","longitude": redacted,"spaceType":"HOME","deviceUUID":"awair-element_19283","deviceId":19283,"locationName":"Berlin, Berlin"}
[1/21/2021, 7:43:01 PM] [Awair2] Initializing platform accessory Awair...
[1/21/2021, 7:43:01 PM] [Awair2] Awair exists, using data from cache
[1/21/2021, 7:43:01 PM] [Awair2] [70886B143462] Getting initial status...awair-element_19283
[1/21/2021, 7:43:02 PM] [Awair2] [70886B143462] updateAirData: []
[1/21/2021, 7:44:15 PM] [Homebridge UI] [admin] Accessory layout changes saved.
[1/21/2021, 7:45:39 PM] [Homebridge UI] [admin] Accessory layout changes saved.
[1/21/2021, 7:45:41 PM] [Homebridge UI] [admin] Accessory layout changes saved.
[1/21/2021, 7:50:24 PM] [Homebridge UI] [admin] Accessory layout changes saved.

Plugin Config:

{
    "bridge": {
        "name": "Homebridge 46A7",
        "username": "redacted",
        "port": 51579,
        "pin": "redacted"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        },
        {
            "token": "eyxxx.eyxxx.xxx",
            "userType": "users/self",
            "airQualityMethod": "awair-aqi",
            "endpoint": "15-min-avg",
            "limit": 1,
            "carbonDioxideThreshold": 1000,
            "carbonDioxideThresholdOff": 800,
            "occupancyDetection": false,
            "occupancyRestart": false,
            "logging": true,
            "verbose": true,
            "development": false,
            "platform": "Awair2"
        }
    ]
}

Screenshots:

Screen Shot 2021-01-21 at 19 45 27

Environment:

Philipp,

Thanks so much for adding Awair2 to your homebridge setup! Thanks also for providing the complete boot log.

Your environment is the same as mine with the exception of running homebridge on MacOS 11.1. I also have the Awair2 plugin running on a Raspberry Pi 4 as a crosscheck.

You are correct, the line that you pointed out is suspicious. Response should be similar to the response which I get from my test Awair-Element with the same config settings as yours:

[1/21/2021, 2:14:48 PM] [Awair2] [70886B140xxx] updateAirData: [{"timestamp":"2021-01-21T19:00:00.000Z","score":99,"sensors":[{"comp":"pm25","value":0.056818181818181816},{"comp":"co2","value":525.875},{"comp":"voc","value":108.73863636363636},{"comp":"temp","value":21.24931801449169},{"comp":"humid","value":47.0127272605896}],"indices":[{"comp":"voc","value":0},{"comp":"co2","value":0},{"comp":"temp","value":0},{"comp":"pm25","value":0},{"comp":"humid","value":0}]}]

I am not immediately seeing any issues in the code for your particular problem. Since you are using config-ui-x, could I ask you to go to the Homebridge Setting (3 vertical dots in upper right hand corner), go to the section "Remove Single Cached Accessory", remove your Awair device from the cache, restart homebridge, and see if the issue remains.

I will continue to check on my end also.

Regards,
Doug

dewey commented

Hey Doug,

thanks for looking into this. I now checked the logs again and it seems like it's getting values now. Even without clearing the cache. Out of curiosity I also went through the "Remove Single Cached Accessory" steps, restarted Homebridge and this time it immediately got values from the device.

I wonder if there's maybe some initial delay from registering the device until the first data is available in the Awair API and that's why it didn't get any data in the first ~1 hour after me setting up the device. This could maybe explain why it just had an empty array there and it's hard to reproduce for you. Maybe it could be reproduced by creating a new Awair account and then immediately requesting the values from the Awair API to check if they show up already.

[1/21/2021, 9:32:08 PM] [Awair2] getAwairDevices: number discovered: 1
[1/21/2021, 9:32:08 PM] [Awair2] getAwairDevices: discovered device: [0] {"name":"Awair","macAddress":"redacted","latitude":redacted,"preference":"GENERAL","timezone":"Europe/Berlin","roomType":"BEDROOM","deviceType":"awair-element","longitude": redacted,"spaceType":"HOME","deviceUUID":"awair-element_19283","deviceId":19283,"locationName":"Berlin, Berlin"}
[1/21/2021, 9:32:08 PM] [Awair2] Initializing platform accessory Awair...
[1/21/2021, 9:32:08 PM] [Awair2] Awair exists, using data from cache
[1/21/2021, 9:32:08 PM] [Awair2] [70886B143462] Getting initial status...awair-element_19283
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462] updateAirData: [{"timestamp":"2021-01-21T20:30:00.000Z","score":92,"sensors":[{"comp":"humid","value":45.10846123328576},{"comp":"temp","value":23.107692131629356},{"comp":"pm25","value":6.769230769230769},{"comp":"co2","value":1095.1538461538462},{"comp":"voc","value":20}],"indices":[{"comp":"humid","value":0},{"comp":"temp","value":0},{"comp":"pm25","value":0},{"comp":"voc","value":0},{"comp":"co2","value":2}]}]
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462] ignoring "humid": 45.10846123328576
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462] ignoring "temp": 23.107692131629356
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462] ignoring "co2": 1095.1538461538462
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462] aqi array: [0,0,1,0,1]
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462] CO2Before: 1
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462] CO2 HIGH: 1095.1538461538462 > 1000
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462] Carbon Dioxide already elevated.
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462] ppb => ug/m^3 equation: (20 * 72.6657827301974 * 1 * 101.32) / ((273.15 + 23.107692131629356) * 8.3144)
[1/21/2021, 9:32:09 PM] [Awair2] [70886B143462]: voc (20 ppb) => tvoc (59.779817265356236 ug/m^3)

I think we can close this as the issue seems to be resolved. Maybe someone else has a similar issue and finds this in the future. So far it looks like the answer is: Be patient

Thanks again for providing this plugin, it seems to work well now!

Best,

Philipp

Thanks for the additional feedback. Glad to hear that the awair2 plugin is now working for you!

I will check with my contact at Awair and see if there is a time delay between getting your token and having it activated. If so, I will update the README file with this information.

One comment is that the awair-aqi method is an averaging measurement. You may want to set your limit to a value > 1. For a 15-min-avg, a setting of 4 would get the average over the last hour.

Closing issue for now. Please let me know if you have any other issues or suggestions. Great to have a European user!

Regards, Doug

Hi @dewey, I work at Awair. @DMBlakeley let me know about this scenario. One question I had: how soon after setting up your Element did you registered for the API and startup your Homebridge setup? Because the plugin is using the 15-min-avg calculation, there needs to be at least 15 minutes or so of initial data in order to rollup the 15-min-avg for a 15 minute block (i.e. :00, :15, :30, :45)

I hope that's the case because it would be the simplest explanation, but if you notice anything else, let us know 👍

dewey commented

Hey Dean,

thanks for also looking into this! This definitely was not the level of support I expected from a small open source project :)

Just downloaded the logs and looked into that. I'm not 100% sure at which point I requested / added the API key but from the logs it looks like there should be enough time inbetween the setup and the empty results. I had this 15 minute in mind while checking for the values but it was empty for longer than that:

[1/21/2021, 6:52:22 PM] [Awair2] getAwairDevices: number discovered: 1
[1/21/2021, 6:52:22 PM] [Awair2] Initializing platform accessory Awair..
[1/21/2021, 6:52:22 PM] [Awair2] [70886B143462] addServices completed
[1/21/2021, 6:52:22 PM] [Awair2] [70886B143462] Getting initial status...awair-element_19283
[ ... 50 min pass by ...]
[1/21/2021, 7:43:02 PM] [Awair2] [70886B143462] updateAirData: []

Who knows if it was just a hiccup though, so maybe a small note that it sometimes could take up to an hour to populate could help prevent confusion in case it happens to anyone else.

Thanks again,

Philipp