lhw / cloudweatherproxy

A HA integration that functions as proxy for weatherstations publishing to Weather Underground and Co
MIT License
5 stars 0 forks source link

No data on Home Assistant (green) 2024.11.1 #34

Open pablolite opened 4 days ago

pablolite commented 4 days ago

System Health details

Home Assistant (green) 2024.11.1

Checklist

Describe the issue

Does the integration work with the latest version of Home Assistant (green) 2024.11.1?

I installed the integration via HACS and added it. A screen appeared with the option to select

image

I checked Weathercloud once, Weather Underground once and both once. None of the settings make the data appear.

On the router I redirected DNS queries and also set on Nginx Proxy Manager to redirect the port from 80 to 8123: Nginx logs show traffic:

10.0.3.92 - - [15/Nov/2024:18:01:43 +0100] "GET /v01/set/wid/xxx/key/xxx/bar/10130 HTTP/1.1" 301 162 "-" "lwIP/2.1.2" 10.0.3.92 - - [15/Nov/2024:18:02:47 +0100] "GET /weatherstation/updateweatherstation.php?ID=xxx&PASSWORD=xxx&dateutc=2024-11-15+17%3A2%3A43&baromin=29.92 HTTP/1.1" 301 162 "-" "lwIP/2.1.2"

Anything else I should set?

Reproduction steps

I installed the integration via HACS and added it.

Debug logs

Diagnostics dump

No response

lhw commented 2 days ago

Did you setup the forward to HA with the access token? You can't simply push use the HA URL from the integration without authentication, HA does not allow that.

  1. Setup a proxying HTTP server that forwards the domains and adds additional information, such as the HomeAssistant access token.

I will have to improve the documentaiton for that by a lot I think.

Go to your user profile in the bottom left. Then at the top Security and there at the bottom create a Long-lived Access Token. Then add it as Header in your nginx-proxy-manager that is send to the backend. Similar to the line here: https://github.com/lhw/cloudweatherproxy/blob/main/examples/Caddyfile#L13 Also note the different URL. So /weatherstation/updateweatherstation.php becomes /wunderground/weatherstation/updateweatherstation.php

pablolite commented 1 day ago

Thanks for the answer. I've generated the token and am trying with the configuration changes, but I'm not sure how it should work.

image image

I set it up as in the screenshots and I get this info in the proxy logs:

/weatherstation/updateweatherstation.php 2024/11/18 16:36:54 [error] 865#865: *651 open() "/var/lib/nginx/html/wunderground" failed (2: No such file or directory), client: 10.0.3.92, server: 10.0.3.185, request: "GET /weatherstation/updateweatherstation.php?ID=IMIECI2&PASSWORD=xxxxxxx&dateutc=2024-11-18+15%3A36%3A38&baromin=29.52&tempf=39.2&humidity=76&dewptf=32.2&rainin=0&dailyrainin=0&winddir=258&windspeedmph=5.5&windgustmph=7.3&UV=0&solarRadiation=0 HTTP/1.1", host: "rtupdate.wunderground.com"

/wunderground/weatherstation/updateweatherstation.php [18/Nov/2024:16:37:59 +0100] - 404 404 - GET http rtupdate.wunderground.com "/weatherstation/updateweatherstation.php?ID=IMIECI2&PASSWORD=xxxxxx&dateutc=2024-11-18+15%3A37%3A56&baromin=29.52&tempf=39.2&humidity=76&dewptf=32.0&rainin=0&dailyrainin=0&winddir=193&windspeedmph=4.9&windgustmph=5.9&UV=0&solarRadiation=0" [Client 10.0.3.92] [Length 14] [Gzip -] [Sent-to 10.0.3.185] "lwIP/2.1.2" "-"

No data appears in any option.

pablolite commented 1 day ago

I did curl directly to HomeAssistant and got an OK response and data appear in the sensor.

C:\Users\pkruszewski>curl -G "http://10.0.3.185:8123/wunderground/weatherstation/updateweatherstation.php" --data-urlencode "ID=IMIECI2" --data-urlencode "PASSWORD=xxxxx" --data-urlencode "dateutc=2024-11-18 18:31:25" --data-urlencode "baromin=29.53" --data-urlencode "tempf=38.2" --data-urlencode "humidity=88" --data-urlencode "dewptf=35.0" --data-urlencode "rainin=0" --data-urlencode "dailyrainin=0.01" --data-urlencode "winddir=270" --data-urlencode "windspeedmph=6.1" --data-urlencode "windgustmph=9.8" --data-urlencode "UV=0" --data-urlencode "solarRadiation=0" -H "Authorization: Bearer xxxxx" OK

lhw commented 1 day ago

Thanks for the answer. I've generated the token and am trying with the configuration changes, but I'm not sure how it should work. [...] No data appears in any option.

I have never used nginx proxy manager. But the second screenshot mentions at the bottom that the header functions do not work in that block. So likely something you have to investigate.

pablolite commented 1 day ago

This configuration works well:

image

location /weatherstation/updateweatherstation.php {
    rewrite ^/weatherstation/updateweatherstation.php(.*)$ /wunderground/weatherstation/updateweatherstation.php$1 break;
    proxy_pass http://10.0.3.185:8123;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Authorization "Bearer xxx";
}
location /v01/set/ {
    rewrite ^/v01/set/(.*)$ /weathercloud/v01/set/$1 break;
    proxy_pass http://10.0.3.185:8123;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Authorization "Bearer xxx";
}

image

The only problem is that data not appear in the cloud (both).

pablolite commented 1 day ago

I compared the sensors that appeared (11) with the data sent in the queries and there is a difference.

Queries sometimes have 11 values and sometimes 12. There is not always a “chill” parameter.

In HomeAssistant it does not appear at all.

[18/Nov/2024:23:39:42 +0100] - 200 200 - GET http api.weathercloud.net "/v01/set/wid/80f7a4ec8e7bbc8b/key/xxx/bar/10022/temp/21/hum/87/wdir/220/wspd/6/dew/1/heat/21/rainrate/0/rain/6/uvi/0/solarrad/0" [Client 10.0.3.92] [Length 2] [Gzip -] [Sent-to 10.0.3.185] "lwIP/2.1.2" "-" [18/Nov/2024:23:39:47 +0100] - 200 200 - GET http api.weathercloud.net "/v01/set/wid/80f7a4ec8e7bbc8b/key/xxx/bar/10022/temp/21/hum/87/wdir/220/wspd/6/dew/1/heat/21/rainrate/0/rain/6/uvi/0/solarrad/0" [Client 10.0.3.92] [Length 2] [Gzip -] [Sent-to 10.0.3.185] "lwIP/2.1.2" "-" [18/Nov/2024:23:39:54 +0100] - 200 200 - GET http api.weathercloud.net "/v01/set/wid/80f7a4ec8e7bbc8b/key/xxx/bar/10022/temp/21/hum/88/wdir/253/wspd/12/dew/3/heat/21/rainrate/0/rain/6/uvi/0/solarrad/0" [Client 10.0.3.92] [Length 2] [Gzip -] [Sent-to 10.0.3.185] "lwIP/2.1.2" "-" [18/Nov/2024:23:41:02 +0100] - 500 500 - GET http api.weathercloud.net "/v01/set/wid/80f7a4ec8e7bbc8b/key/xxx/bar/10022/temp/23/hum/87/wdir/188/wspd/14/dew/3/chill/9/heat/23/rainrate/0/rain/6/uvi/0/solarrad/0" [Client 10.0.3.92] [Length 55] [Gzip -] [Sent-to 10.0.3.185] "lwIP/2.1.2" "-" [18/Nov/2024:23:41:08 +0100] - 500 500 - GET http api.weathercloud.net "/v01/set/wid/80f7a4ec8e7bbc8b/key/xxx/bar/10022/temp/23/hum/87/wdir/188/wspd/14/dew/3/chill/9/heat/23/rainrate/0/rain/6/uvi/0/solarrad/0" [Client 10.0.3.92] [Length 55] [Gzip -] [Sent-to 10.0.3.185] "lwIP/2.1.2" "-"

pablolite commented 14 hours ago

I analyzed the code and the missing of this sensor was due to its lack in the [aiocloudweather] library . I added it and asked it to be included.