Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response missing "obs" data, returning last cached response #5

Closed
DMBlakeley opened this issue Feb 8, 2023 · 9 comments
Closed

Response missing "obs" data, returning last cached response #5

DMBlakeley opened this issue Feb 8, 2023 · 9 comments
Labels
question Further information is requested

Comments

@DMBlakeley
Copy link
Collaborator

Describe Your Problem:

Several times per day I receive the error shown in the logs below. The plugin is configured as a Child Bridge and starts without issue. Data being reported seems correct. Would like to understand how to eliminate this error.

I also have a Home-Assistant plugin also polling the Weatherflow-Tempest data.

Logs:

[2/7/2023, 6:25:26 PM] [WeatherFlow Tempest Platform] Response missing "obs" data.
[2/7/2023, 6:25:26 PM] [WeatherFlow Tempest Platform] Returning last cached response.

Plugin Config:

{
    "name": "WeatherFlow Tempest Platform",
    "token": "05d8d2db-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "station_id": 12345,
    "interval": 20,
    "sensors": [
        {
            "name": "Tempest Temperature",
            "sensor_type": "Temperature Sensor",
            "value_key": "air_temperature"
        },
        {
            "name": "Tempest Relative Humidity",
            "sensor_type": "Humidity Sensor",
            "value_key": "relative_humidity"
        },
        {
            "name": "Tempest Light Level",
            "sensor_type": "Light Sensor",
            "value_key": "brightness"
        },
        {
            "name": "Tempest Wind Speed",
            "sensor_type": "Fan",
            "value_key": "wind_avg"
        }
    ],
    "_bridge": {
        "username": "0E:5B:xx:xx:xx:xx",
        "port": 50691
    },
    "platform": "WeatherFlowTempest"
}

Screenshots:

Environment:

  • Plugin Version:
  • Homebridge Version: v1.6.2
  • Node.js Version: v18.14.0 (problem also occurred on prior v16 and v18 node versions)
  • NPM Version: 8.19.2
  • Operating System: MacOS Ventura 13.2
@DMBlakeley DMBlakeley added the question Further information is requested label Feb 8, 2023
@DMBlakeley
Copy link
Collaborator Author

Now seeing additional error:

[2/9/2023, 5:19:18 PM] [WeatherFlow Tempest Platform] TypeError: Cannot read properties of undefined (reading 'air_temperature') at TemperatureSensor.getCurrentTemperature (/usr/local/lib/node_modules/homebridge-weatherflow-tempest/src/platformAccessory.ts:43:76) at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-weatherflow-tempest/src/platformAccessory.ts:29:75) at listOnTimeout (node:internal/timers:569:17) at processTimers (node:internal/timers:512:7)

Which repeats for each of the configured sensors.

@chasenicholl
Copy link
Owner

The first issue happens when the WeatherFlow Tempest REST API fails to respond - it's a networking error.

  1. Your Tempest hub temporarily disconnects from WiFi and subsequently discounts from the WeatherFlow servers.
  2. Your home internet happens to briefly disconnect (which would also cause the above).
  3. The WeatherFlow Tempest API itself fails to respond for whatever reason.

You can always trying manually calling the API and confirming your station responds with the correct JSON structure. There should be a top level key called obs that contains the "observation" data for station that this plugin relies on.

curl https://swd.weatherflow.com/swd/rest/observations/station/{insert your station id} --header "Authorization: Bearer {insert your token}"

As for your second exception I'm not sure yet, I'll take a look.

@DMBlakeley
Copy link
Collaborator Author

Hello Chase,

Thanks for making this plugin available and the detailed response.

In my home automation setup, I believe that #3 is the most likely for producing the error. My thoughts are:

  • I have no indiction from the Tempest app that the PWS is going off line.
  • I checked that the suggested curl provided the expected JSON response for the obs key.
  • I do, however, also have have an instance of Home-Assistant running with the WeatherFlow integration.

My current theory is that with two different WeatherFlow apps polling the WeatherFlow server there is a pretty good chance that they could be sampling at the same time resulting in one app being rejected.

I am in the process of verifying this theory and understand best way to address. Will get back to you with my findings.

Regards,
Doug

@kskenyon
Copy link

kskenyon commented Feb 27, 2023 via email

@DMBlakeley
Copy link
Collaborator Author

@kskenyon, thanks for the suggestion. Checked and the token has no trailing space. The error occurrence is pretty random and the Tempest data as viewed through homebridge or HomeKit is correct.

@DMBlakeley
Copy link
Collaborator Author

Hello Chase,

I have spent quite a bit of time trying to understand these errors.

I agree with you that the Response missing "obs" data is most likely a Server error. I added a check into the axios call in the getStationObservation function call to check that the Server is online before resolving. Error still happens occasionally but is handled in a clean manner so not really a big issue.

The second undefined error is really puzzling. The best hypothesis that I have come up with is that one sampling loop which is the Observation array. In parallel there are multiple sampling loops which are updating air_temperatuer, relative_humidity, brightness and wind_avg. If the parallel loops overlap the sampling loops you find yourself in an undefined condition.

I also have a homebridge plugin (homebridge-awair2) which takes a different approach of sampling and then updating. Believe this approach would address the issue but it is a pretty big change to your coding approach. I am certainly not a software engineer by any means and like the elegance of your approach but just cannot see a straight forward way to address.

Regards,
Doug

@DMBlakeley
Copy link
Collaborator Author

I believe I have been able to address and found additional error in the process. Will be submitting a Pull Request this week for your consideration.

Regards, Doug

@chasenicholl
Copy link
Owner

@DMBlakeley thanks looking forward to reviewing it!

@DMBlakeley
Copy link
Collaborator Author

DMBlakeley commented Mar 11, 2023

@chasenicholl I have submitted a change request to address the runtime errors. Changes are summarized in the CHANGE.MD file which I created. The second error noted above is now being trapped. I am not 100% sure of the root cause and my changes may trigger some thought on your part. A possible issue is that getStationCurrentObservation will create a nested subroutine until retry_count is exhausted.

Something else that needs to be addressed is that deleted Accessories are not removed if you delete or rename in the config file.

Looking forward to your feedback.

Regards, Doug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants