home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.55k stars 30.35k forks source link

Netatmo Integration error at Startup: Error during webhook registration - 400 - Bad request #40699

Closed ktvanzwol closed 3 years ago

ktvanzwol commented 4 years ago

The problem

At startup of home assistant the Netatmo Integration generates a error message. This does not seem to be critical for my usage as it seems to work fine, I'm only using a Netatmo weather station.

Environment

Problem-relevant configuration.yaml

No yaml based configuration, connected with Netatmo trough the Netatmo Intergration UI.

Traceback/Error logs

Log Details (ERROR)
Logger: homeassistant.components.netatmo
Source: components/netatmo/__init__.py:159
Integration: Netatmo (documentation, issues)
First occurred: 9:48:37 AM (1 occurrences)
Last logged: 9:48:37 AM

Error during webhook registration - 400 - Bad request - Allowed ports for webhooks are 443 and 80. (21) when accessing 'https://api.netatmo.com/api/addwebhook'

Additional information

probot-home-assistant[bot] commented 4 years ago

netatmo documentation netatmo source (message by IssueLinks)

probot-home-assistant[bot] commented 4 years ago

Hey there @cgtobi, mind taking a look at this issue as its been labeled with an integration (netatmo) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

Metus88 commented 4 years ago

Have you tried to open ports 443 and 80 in your router and forward them to your homeassistant internal ip? This can fix the problem.... but maybe you prefer don't open port in your router so the best is take the message in the log and ignore it. Give me a feedback if open the ports works

cgtobi commented 4 years ago

The webhook is not required for most Netatmo devices to work, but it improves responsiveness. In case of outdoor cameras and smoke detectors it is actually required.

To use the webhook you eiher need to expose HA to the web (securely) for example through a reverse proxy or you subscribe to Nabu Casa, which does all that for you and supports the project.

If you don't need all of that, you can safely ignore that message.

ktvanzwol commented 4 years ago

Thanks that explains it, maybe good to update the documentation to include the information on webhooks at some point. I'll ignore the error.

sany1231 commented 4 years ago

Same issue here but no luck with solving it. After one of my upgrades to 0.115.6 i no longer see data from netatmo in home-assistant. Some users recomended me to upgrade further to 0.116.2 but still not working.

ERROR (MainThread) [homeassistant.components.netatmo] Error during webhook registration - 400 - Bad request - Allowed ports for webhooks are 443 and 80. (21) when accessing 'https://api.netatmo.com/api/addwebhook'

  1. My hass is directly connected to outside world via 443 port (80 is too but is redirected to 443 automaticaly), so please do not suggest to check if ports are correctly opend because if wont then whole hass will not working.

  2. I did nothing to netatmo configuration since 0.112.x so if there was no updates in config then everytning shoul be configured fine.

cgtobi commented 4 years ago

Apart from the error about the webhook being reported do you have any functional issues with the integration?

sany1231 commented 4 years ago

Apart from the error about the webhook being reported do you have any functional issues with the integration?

I see no data from my modules in hass so i suppose, that is functiuonal issue, because all my outdoor automations base on temp/humid sensors from outside unit are not functional. Same automation problem with temperature regulation in room where is placed indoor module.

But i see all data on netatmo page.

And only error i see in log is that 443 webhook

cgtobi commented 4 years ago

Please go to the configuration panel and navigate to you netatmo devices. Check all of them there if the individual entities do contain anything or all report unavaiblable for example. A (few) screenshot(s) could help maybe.

sany1231 commented 4 years ago

Please go to the configuration panel and navigate to you netatmo devices. Check all of them there if the individual entities do contain anything or all report unavaiblable for example. A (few) screenshot(s) could help maybe.

Sorry i did not mentioned, that after upgrade to 0.115.6 i had all entities unavailable, so i did what someone suggested to do, i removed netatmo integration, i created new netatmo dev app (key, secret) and add new integration with new keys into hass. But now i see no device and no entities at all.

Actual version of hass 0.116.2

netatmo configuration and netatmo integration

hass-netatmo2 hass-netatmo1

cgtobi commented 4 years ago

I'd suggest to run the self test script with those new set of keys to check what's actually returned by the back end.

sany1231 commented 4 years ago

I used another solution for testing netatmo api because yours were showing this error

Traceback (most recent call last): File "gen_test_data.py", line 6, in <module> import pyatmo # for version >=3.2.0 File "/usr/local/lib/python3.5/dist-packages/pyatmo/__init__.py", line 1, in <module> from .auth import ClientAuth, NetatmoOAuth2 File "/usr/local/lib/python3.5/dist-packages/pyatmo/auth.py", line 115 json_params: Optional[str] = params.pop("json")

I used this one https://github.com/mr3188/PyAtmo and i tried to generate access token and i it works fine. Next i am going to try to collect same data.

cgtobi commented 4 years ago

The error occurs because the python version is not supported anymore by pyatmo. Please use 3.7 or newer.

sany1231 commented 4 years ago

I did my own script based on netatmo API and everything is working as should.

{'beg_time': 1601546400, 'value': [[23.3], [23.1], [23.5], [23.9], [23.7], [23.3], [22.1], [22.2], [22.1], [22.1], [21.9], [21.6]], 'step_time': 86400}

This is my room temerature in 1day scale. I used my ID & SECRET -> generate ACCESS_TOKEN -> then i can call any reqeust from API DOC and it is working.

So what is next move ?

cgtobi commented 4 years ago

Is your script using pyatmo?

sany1231 commented 4 years ago

Is your script using pyatmo?

No, i am using only python requests lib

cgtobi commented 4 years ago

In that case this is not much use for me.

cianial commented 3 years ago

I get same Webhook error ( Error during webhook registration - 400 - Bad request - Allowed ports for webhooks are 80, 88, 443 and 9443. (21) when accessing 'https://api.netatmo.com/api/addwebhook') so I used your script using pyatmo and everything seem ok:

`(venv) alessandro@nucha:~$ python gen_test_data.py --CLIENT_ID 5baeba3a923dfe83f88cfe2f --CLIENT_SECRET eAqVo7XxLZleMwfpJqPz8iuB3P8nvGR43iaPd --USERNAME 'alessandro.ciani@gmail.com' --PASSWORD 'Miccine#60_delle_Therm' --mode long Energy Public Camera WeatherStation HomeCoach Smokedetector

Checking for available weather stations... warning, no weather station available for testing

Checking for available home coach stations... Camera (70:ee:50:26:1d:f4) Modules ['Indoor'] Temperature - 19.9 CO2 - 492 Humidity - 49 Noise - 41 Pressure - 1001.9 AbsolutePressure - 997.3 health_idx - 0 min_temp - 19 max_temp - 20.5 date_max_temp - 1609562916 date_min_temp - 1609605498 When - 1609613350 reachable - True wifi_status - 51 HomeCoach [OK]

Checking for available cameras... Miccine60 (5971ba19ac34a555668b4c38) Camera [OK]

Checking for available smoke detectors... Miccine60 (5971ba19ac34a555668b4c38) Smoke detector [OK]

Checking for public data... Average temperature: 1.40°C Average humidity: 91.25 % Available stations: 4 Public [OK]

Checking for available thermostats/valves... Miccine60 (5971ba19ac34a555668b4c38) NAPlug Soffitta (70:ee:50:0a:52:bc) Cucina (29713021) Measured room temperature 21°C Thermostat Termostato Cucina (04:00:00:0a:1b:b6) Boilerstatus: True Setpoint Mode: schedule Energy [OK] ` but when I look in my home coach stations device in the configuration/integration I get Min and Max temp unavailable (see the picture) image

cgtobi commented 3 years ago

Min and max is not available any more. And the error during webhook registration simply means that your instance is not exposed to work with the Netatmo backend. If you don't need the webhook events you can ignore it.

diversit commented 3 years ago

This week I also experienced that all Netatmo entities were 'unavailable' and the logs showed the same Webhook error mentioned in other comments. Even after removing and re-add the integration the same error kept and no data for the Netatmo entities. Now, next morning, I notice the entities now do have values again. So it somehow restored by itself.

I only have the weather station and I do not want to open up any port into my home for a webhook since that is just a security risk.

@cgtobi Is it correct that when the webhook is not available, the integration falls back to polling? Could it be that a polling rate-limit is reached causing the values to become unavailable? I see that the Netatmo rate limits should be quite sufficient for a polling application. I assume every HomeAssistant integration counts as a new application/user and not via some common HA-Netatmo integration service in the cloud.

Since it's only the weather station for me, I'm more than happy with new values every 10min. I vaguely remember this used to be a configuration option. Is it still possible to set this polling interval somehow?

cgtobi commented 3 years ago

The webhook message can be safely ignored for weather stations as it does not provide data this way and is always polling. The polling frequency can not me changes by the user.

Netatmo had server issues in the past days. Usually the sensors just come back once the backend is fixed.

kentania commented 3 years ago

Hello everybody. Excuse me but I've been trying to get webhoocks for a while but despite the research I don't understand what I'm doing wrong or what I'm missing and I keep getting this error: Logger: homeassistant.components.netatmo Source: components / netatmo / init.py:187 Integration: Netatmo (documentation, issues) First occurred: 20:15:50 (1 occurrences) Last logged: 20:15:50

Error during webhook registration - 400 - Bad request - Allowed ports for webhooks are 80, 88, 443 and 9443. (21) when accessing 'https://api.netatmo.com/api/addwebhook'

hass.io 5.12 supervisor-2021.03.4 core-2021.3.4 duckdns and nginx installed so rpi4 can be reached from both http://my.duckdns.org and https://my.duckdns.org (ports 80 and 443 open on the router). netatmo configured via configuration.yaml in configuration.yaml I put netatmo: client_id: myclienid client_secret: mycliensecret http: base_url: https://my.duckdns.org in dev.netatmo.com do I have to put something in redirect url or webhook url?

I have both thermostats, valves and a couple of presences, they work regularly but I can't get the status of the lights that are unavailable, in fact I get the error: Logger: homeassistant.components.light Source: helpers / entity_platform.py: 216 Integration: Luce (documentation, issues) First occurred: 20:15:50 (1 occurrences) Last logged: 20:15:50

Platform netatmo not ready yet. Retrying in 30 seconds.

Can anyone help me?

cgtobi commented 3 years ago

Have you set the external url under /config/core?

kentania commented 3 years ago

Found, it was set from before Nginx with: 8123, and I forgot to correct it ... in 2 minutes you solved a 15 day gripe, thank you very much!

Light.netatmo has already started working too!

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.