tlskinneriv / awnet_local

Enables local support for Ambient Weather personal weather stations.
26 stars 5 forks source link

ERROR : Query string could not be detected in the request. Is the query string character '?' in the path? #27

Closed JtwoA closed 1 year ago

JtwoA commented 1 year ago

Integration Version: 1.0.0

Home Assistant Version: Home Assistant 2023.6.1 Supervisor 2023.06.1 Operating System 10.2 Frontend 20230608.0 - latest

Describe the bug Logs show error about query string

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Successful polling

Screenshots image (Yes, the fourth octet was purposefully removed from the screenshot - it's present in the app)

Additional context "Configuration is performed via the Home Assistant user interface." - where is this done? I manually added MAC address to services.yaml

Phone is iPhone 14p with AWNET v4.3.4 and Ambient Wx Stn 2902A

Debug log output from the integration (see Home Assistant docs for how to enable debug logging for an integration; integration name: "custom_components.awnet_local")

192.168.1.xxx - - [09/Jun/2023 17:02:49] "GET /data/report/stationtype=AMBWeatherV4.3.4&PASSKEY=XX:7D:3A:7C:1D:XX&dateutc=2023-06-09+21:02:47&tempinf=74.1&humidityin=55&baromrelin=29.643&baromabsin=29.767&tempf=81.7&humidity=54&winddir=113&windspeedmph=2.7&windgustmph=3.4&maxdailygust=9.2&hourlyrainin=0.000&eventrainin=0.000&dailyrainin=0.000&weeklyrainin=1.142&monthlyrainin=1.142&totalrainin=236.220&solarradiation=415.57&uv=4&batt_co2=1 HTTP/1.1" 400 20
2023-06-09 17:03:21,274    ERROR : Query string could not be detected in the request. Is the query string character '?' in the path?
tlskinneriv commented 1 year ago

Yes, the '?' is required to be at the end of the path. It could be the only character in the path also. Adding this should allow the add-on to work properly.

JtwoA commented 1 year ago

Pardon the ignorance - what path?

JtwoA commented 1 year ago

Nevermind - momentary brain lapse. All set. Data is flowing. Thanks!

JtwoA commented 1 year ago

Urgh, watching the logs go by and I see errors.

2023-06-09 18:30:49,225    ERROR : Failed to send {"/data/report/stationtype": "AMBWeatherV4.3.4", "PASSKEY": "xx:xx:xx:xx:xx:xx", "dateutc": "2023-06-09 22:30:47", "tempinf": "74.8", "humidityin": "54", "baromrelin": "29.670", "baromabsin": "29.794", "tempf": "80.2", "humidity": "53", "winddir": "56", "windspeedmph": "0.9", "windgustmph": "1.1", "maxdailygust": "9.2", "hourlyrainin": "0.000", "eventrainin": "0.000", "dailyrainin": "0.000", "weeklyrainin": "1.142", "monthlyrainin": "1.142", "totalrainin": "236.220", "solarradiation": "166.99", "uv": "1", "batt_co2": "1"} to http://supervisor/core/api/services/awnet_local/update with headers {'Authorization': 'Bearer 73e933520b75c096d431393a825ee6e6290b965171xxxxxxxxxxxxxx647167bdb0e901392fa67188eeddafbb0651bf818e527db61f37b375', 'content-type': 'application/json'}; b'400: Bad Request'
192.168.1.xxx - - [09/Jun/2023 18:30:49] "GET ?/data/report/stationtype=AMBWeatherV4.3.4&PASSKEY=xx:xx:xx:xx:xx:xx&dateutc=2023-06-09+22:30:47&tempinf=74.8&humidityin=54&baromrelin=29.670&baromabsin=29.794&tempf=80.2&humidity=53&winddir=56&windspeedmph=0.9&windgustmph=1.1&maxdailygust=9.2&hourlyrainin=0.000&eventrainin=0.000&dailyrainin=0.000&weeklyrainin=1.142&monthlyrainin=1.142&totalrainin=236.220&solarradiation=166.99&uv=1&batt_co2=1 HTTP/1.1" 200 0
tlskinneriv commented 1 year ago

Was the '?' put at the end of the Path? I edited my response earlier and failed to mark it edited.

Path in the app can also be set to just the '?' character.

tlskinneriv commented 1 year ago

Also, please see the docs at https://github.com/tlskinneriv/hassio-addons/blob/master/awnet/DOCS.md for more details on the add-on setup.

JtwoA commented 1 year ago
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
2023-06-09 19:11:24,681     INFO : Serving on http://localhost:80
2023-06-09 19:11:33,145    ERROR : Failed to send {"stationtype": "AMBWeatherV4.3.4", "PASSKEY": "redacted", "dateutc": "2023-06-09 23:11:31", "tempinf": "74.1", "humidityin": "52", "baromrelin": "29.687", "baromabsin": "29.811", "tempf": "80.1", "humidity": "57", "winddir": "123", "windspeedmph": "0.0", "windgustmph": "0.0", "maxdailygust": "9.2", "hourlyrainin": "0.000", "eventrainin": "0.000", "dailyrainin": "0.000", "weeklyrainin": "1.142", "monthlyrainin": "1.142", "totalrainin": "236.220", "solarradiation": "92.73", "uv": "0", "batt_co2": "1"} to http://supervisor/core/api/services/awnet_local/update with headers {'Authorization': 'Bearer fc23a0015617a1c8e8df18af2e47fbf8091100899116f67fxxxxxxxxxxxxxxxb8bd1d014f701aa8b29c94ee48f21c5e073a3e48', 'content-type': 'application/json'}; b'400: Bad Request'
192.168.1.xxx - - [09/Jun/2023 19:11:33] "GET ?stationtype=AMBWeatherV4.3.4&PASSKEY=redacted&dateutc=2023-06-09+23:11:31&tempinf=74.1&humidityin=52&baromrelin=29.687&baromabsin=29.811&tempf=80.1&humidity=57&winddir=123&windspeedmph=0.0&windgustmph=0.0&maxdailygust=9.2&hourlyrainin=0.000&eventrainin=0.000&dailyrainin=0.000&weeklyrainin=1.142&monthlyrainin=1.142&totalrainin=236.220&solarradiation=92.73&uv=0&batt_co2=1 HTTP/1.1" 200 0

App settings: Use the "Next" button in the upper right to navigate to the "Customized" page Configure the customized data upload with the following: Protocol Type Same As: Ambient Weather (Y) Server IP / Hostname: (your Home Assistant IP/hostname) (Y - server IP) Path: ? (Literally the '?' character to send the data as a query string to the web server) (Y) Port: (Port the add-on is listening on, default 7080) (Y) Upload Interval: (user determined, how often to send data to Home Assistant) (Y) Click "Save" at the bottom of the form (Y) Use the "Finish" button in the upper right to complete configuration (No finish button in iOS app version) image

tlskinneriv commented 1 year ago

Looks like the add-on is set up correctly now but the service isn't listening.

Has the integration been set up with the correct MAC address? Have you restarted HA as a troubleshooting step after having the add-on working?

JtwoA commented 1 year ago

I edited the services.yaml to have the MAC address. Confirmed it is correct. Restarted HA a few times but not sure if after the latest changes in the app (did restart the add-on) so I've done it again just now.

Same result.

It's pulling the data from the 2902A, it's falling down here:

ERROR : Failed to send <all the right data is present> to http://supervisor/core/api/services/awnet_local/update with headers {'Authorization': 'Bearer fc23a0015617a1c8e8df18af2e47fbf8091100899116f67f036262a4eb7randomGUIDbd1d014f701aa8b29c94ee48f21c5e073a3e48', 'content-type': 'application/json'}; b'400: Bad Request'
tlskinneriv commented 1 year ago

What's being configuring in services.yaml? I did not write a YAML configuration processor in for this integration. The integration should be configured entirely from the UI.

JtwoA commented 1 year ago

I got no config dialogue in HA.

tlskinneriv commented 1 year ago

Interesting. After adding the integration in HACS (or copying the awnet_local folder into your custom_components folder) and restarting HA, you should have an option to select it on the page to add an integration in the UI.

Are there any errors showing for the custom_components.awnet_local module in the HA logs? I don't have any issue getting the GUI dialog to show when adding the integration, and I'm running 2023.6.1 as well.

I've noticed sometimes when adding a new integration from HACS or elsewhere that sometimes I need to clear my web browser cache for it to show up in the pick list. Perhaps you're having the same issue if it's not showing in the list.

JtwoA commented 1 year ago

That did it!

Cleared the browser cache, restarted HA, relogged into HA, add integration and it was there.

Thanks!