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
69.74k stars 28.91k forks source link

API Error - Ambient Weather Station #90181

Open marcoGH9 opened 1 year ago

marcoGH9 commented 1 year ago

The problem

Hi, when I try to enter the API Key and Application Key in the Ambient Weather Station form I get an API Error. How come the hexadecimal string that works in other services is not accepted here? Thank you all

What version of Home Assistant Core has the issue?

2023.3.6

What was the last working version of Home Assistant Core?

2023.3.6

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

No response

Link to integration documentation on our website

https://www.home-assistant.io/integrations/ambient_station/

Diagnostics information

error API

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @bachya, mind taking a look at this issue as it has been labeled with an integration (ambient_station) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `ambient_station` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign ambient_station` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


ambient_station documentation ambient_station source (message by IssueLinks)

bachya commented 1 year ago

I will need to see both diagnostics and debug-level logs to diagnose furtherβ€”in your configuration.yaml, you can set debug-level logs via:

logger:
  default: error
  logs:
    homeassistant.components.ambient_station: debug
    aioambient: debug
marcoGH9 commented 1 year ago

I'm trying (it's the first time I use HA) and I don't think I can provide you with the logs...

marcoGH9 commented 1 year ago

The Error is: "Invalid API key"

bachya commented 1 year ago

The error is pretty self-explanatory.

I just started up a fresh HASS and the Ambient integration loaded fine, so I doubt there's a systemic issue. Without logs and diagnostics, I'm unable to know for sure.

Are you perhaps swapping your app key and API key?

eea123 commented 1 year ago

I'm having the same issue. Ambient Weather's Dashboard only generates an API Key, the app key is blank.

I submitted a help ticket into Ambient Weather.

KCKgithub commented 1 year ago

Home Assistant 2023.4.4 Frontend 20230411.1 - latest

API and APP key entered correctly and accepted. Ambientweather.net dashboard is being updated successfully.

2023-04-17 15:01:02.349 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-04-17 15:01:10.701 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=key&transport=websocket&EIO=3
2023-04-17 15:01:11.127 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error
2023-04-17 15:01:11.132 WARNING (MainThread) [homeassistant.config_entries] Config entry 'device_id' for ambient_station integration not ready yet: Connection error; Retrying in background
2023-04-17 15:01:11.490 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector
2023-04-17 15:01:17.347 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=key&transport=websocket&EIO=3
2023-04-17 15:01:17.643 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error
2023-04-17 15:01:18.433 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1767, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service notify.mobile_app_p5
2023-04-17 15:01:18.464 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1767, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service notify.mobile_app_p5
2023-04-17 15:01:18.563 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1767, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service notify.mobile_app_p5
2023-04-17 15:01:18.669 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1767, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service notify.mobile_app_p5
2023-04-17 15:01:18.752 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1767, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service notify.mobile_app_p5
2023-04-17 15:01:18.845 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1767, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service notify.mobile_app_p5
2023-04-17 15:01:18.889 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1767, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service notify.mobile_app_p5
2023-04-17 15:01:19.688 ERROR (SyncWorker_6) [homeassistant] Error doing job: Unclosed client session
2023-04-17 15:01:19.730 ERROR (SyncWorker_6) [homeassistant] Error doing job: Unclosed connector
2023-04-17 15:01:27.748 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=keyf&transport=websocket&EIO=3
2023-04-17 15:01:27.859 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error
2023-04-17 15:01:29.304 ERROR (SyncWorker_2) [homeassistant] Error doing job: Unclosed client session
2023-04-17 15:01:29.308 ERROR (SyncWorker_2) [homeassistant] Error doing job: Unclosed connector
2023-04-17 15:01:48.187 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=key&transport=websocket&EIO=3
2023-04-17 15:01:48.303 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error
2023-04-17 15:01:49.645 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2023-04-17 15:01:49.651 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector
2023-04-17 15:02:28.759 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=key&transport=websocket&EIO=3
2023-04-17 15:02:28.872 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error
2023-04-17 15:02:29.646 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2023-04-17 15:02:29.650 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector
2023-04-17 15:03:49.049 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=key&transport=websocket&EIO=3
2023-04-17 15:03:49.168 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error
2023-04-17 15:03:49.650 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2023-04-17 15:03:49.651 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector
wmichael3 commented 1 year ago

I just started getting this identical problem - it has worked perfectly until this morning. When I run an API query in a browser of the form: (not my real api and app keys or device MAC)

https://api.ambientweather.net/v1/devices/EC:QQ:GG:80:75:74?apiKey=5ad8862e988943a3a614c6dbd6d41ce&applicationKey=0c526fdaae619a36ef7ac64c6557&limit=1

I get data back successfully, so the API is up.

EDIT:
This websockets call is failing - this call shows up in the log and I used an online sockets tester to verify the failure:

- Connecting to: wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=0c526fdaae29476fae4s;dlfks;dlfks;dfks;dflk4d619a36ef7ac64c6557&transport=websocket&EIO=3

- Connection failed, see your browser's [developer console](https://developers.google.com/web/tools/chrome-devtools/open) for reason and error code.

- Connection closed

My browser recorded this error: _"caught (in promise) Error: Could not establish connection. Receiving end does not exist."_

When I run that same URL with http instead of wss, I get an http 503, service temporarily unavailable.  I did that because the API docs mention using http.

These are the repeated errors in the log. I first noticed this after updating to 2023.4.4, but rolled back to 2023.4.1 and the error remains. (HA Core)

2023-04-17 10:49:48.166 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error 2023-04-17 10:49:50.367 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session 2023-04-17 10:49:50.381 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector 2023-04-17 10:49:58.466 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error 2023-04-17 10:50:00.491 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session 2023-04-17 10:50:00.497 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector 2023-04-17 10:50:19.236 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error 2023-04-17 10:50:19.256 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session 2023-04-17 10:50:19.259 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector 2023-04-17 10:50:59.708 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error 2023-04-17 10:51:00.212 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session 2023-04-17 10:51:00.217 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector 2023-04-17 10:52:20.275 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error 2023-04-17 10:52:24.355 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session 2023-04-17 10:52:24.358 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector

roechas commented 1 year ago

I just started having this issue this morning as well. Just stopped updating my sensors. I restarted HASS and now the entities show as unavailable.

Log: 2023-04-17 12:16:05.955 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error 2023-04-17 12:16:05.957 WARNING (MainThread) [homeassistant.config_entries] Config entry '00fef5cf1539' for ambient_station integration not ready yet: Connection error; Retrying in background 2023-04-17 12:17:03.809 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error

heylers commented 1 year ago

Mine just broke today as well ....

SMac3265 commented 1 year ago

You can add me to the "mine broke this morning" list too. Was working great for about 3 weeks, then this morning... the wheels fell off.

smaegley commented 1 year ago

Same issue started for me this morning as well. Tried setting up a new app key and retrying but I'm still getting this error. Logger: homeassistant.components.ambient_station Source: components/ambient_station/init.py:78 Integration: Ambient Weather Station (documentation, issues) First occurred: 12:24:49 PM (16 occurrences) Last logged: 12:31:27 PM

Config entry failed: Connection error

bachya commented 1 year ago

TO ALL FUTURE COMMENTERS: Unless you have additional, concrete info, please do not post "me too" comments, as they clutter the conversation. You can add a πŸ‘πŸ» to the original issue post to indicate that you are experiencing the issue.

tokenwizard commented 1 year ago

I recently had this issue as well. After you create the API/APP keys in the Ambient Weather Dashboard, copy them to a text file and close the Ambient Weather page. Then go into Home Assistant and add the integration.

It seems Ambient Weather does not actually save the APP/API keys until you close out.

SMac3265 commented 1 year ago

I recently had this issue as well. After you create the API/APP keys in the Ambient Weather Dashboard, copy them to a text file and close the Ambient Weather page. Then go into Home Assistant and add the integration.

It seems Ambient Weather does not actually save the APP/API keys until you close out.

I tried doing that, and I still get a connection error.

I deleted the integration, and reinstalled it. I pasted in the API and APP keys from a text editor after I closed out of ambientweather.net. Still get the connection error.

Here is the associated log entry:

Logger: homeassistant.components.ambient_station Source: components/ambient_station/init.py:78 Integration: Ambient Weather Station (documentation, issues) First occurred: 13:26:55 (97 occurrences) Last logged: 15:08:23

Config entry failed: Connection error

tokenwizard commented 1 year ago

Interesting. That "trick" literally worked for me about an hour ago when I was repeatedly trying to re-add my Ambient Weather integration and getting that Invalid API Key error. Now it took my API Key and added the integration but it is still failing to connect and display and sensor data.

bachya commented 1 year ago

I've posted an issue in their API docs repo (they're usually reasonably quick to respond): https://github.com/ambient-weather/api-docs/issues/47

SMac3265 commented 1 year ago

OK... well just like that, my weather information magically appeared on my display again.

tokenwizard commented 1 year ago

Same! Seems like maybe the Issue logged with Ambient Weather by @bachya prompted them to realize something was broken.

Mermarky commented 1 year ago

Since yesterday.... It was working for quite sometime:

2023-04-18 10:22:35.366 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Ambient Weather for ambient_station Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup result = await component.async_setup_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/ambient_station/init.py", line 76, in async_setup_entry await ambient.ws_connect() File "/usr/src/homeassistant/homeassistant/components/ambient_station/init.py", line 195, in ws_connect await self.websocket.connect() File "/usr/local/lib/python3.10/site-packages/aioambient/websocket.py", line 226, in connect await self._sio.connect( File "/usr/local/lib/python3.10/site-packages/socketio/asyncio_client.py", line 109, in connect await self.eio.connect(url, headers=headers, File "/usr/local/lib/python3.10/site-packages/engineio/asyncio_client.py", line 111, in connect return await getattr(self, 'connect' + self.transports[0])( File "/usr/local/lib/python3.10/site-packages/engineio/asyncio_client.py", line 306, in _connect_websocket ws = await self.http.ws_connect( File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 779, in _ws_connect resp = await self.request( File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect return await fut asyncio.exceptions.CancelledError 2023-04-18 10:22:35.989 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for stage 2 - moving forward

Mermarky commented 1 year ago

and one more log:

2023-04-18 10:18:41.630 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: ambient_station 2023-04-18 10:19:41.714 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: ambient_station 2023-04-18 10:20:41.789 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: ambient_station 2023-04-18 10:21:41.866 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: ambient_station 2023-04-18 10:22:35.366 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Ambient Weather for ambient_station File "/usr/src/homeassistant/homeassistant/components/ambient_station/init.py", line 76, in async_setup_entry File "/usr/src/homeassistant/homeassistant/components/ambient_station/init.py", line 195, in ws_connect

bachya commented 1 year ago

TO EVERYONE EXPERIENCING THE ISSUE: is it still occurring? We've gotten word that AWN may have fixed the issue in their end. Try reloading your Ambient integration.

tokenwizard commented 1 year ago

Mine reloaded without issue and appears to be working as expected.

Mermarky commented 1 year ago

not for me :( I still have an error after reloading :(

2023-04-18 14:41:26.615 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Ambient Weather for ambient_station File "/usr/src/homeassistant/homeassistant/components/ambient_station/init.py", line 76, in async_setup_entry File "/usr/src/homeassistant/homeassistant/components/ambient_station/init.py", line 195, in ws_connect

aggressive-stag commented 1 year ago

Same exact issues for me. All of mine started on the 7th of April it appears. I had been hoping it would just solve out, but it has been bugging out still. Here is my error log with everything up to date as of today:

traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup result = await component.async_setup_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/ambient_station/init.py", line 76, in async_setup_entry await ambient.ws_connect() File "/usr/src/homeassistant/homeassistant/components/ambient_station/init.py", line 195, in ws_connect await self.websocket.connect() File "/usr/local/lib/python3.10/site-packages/aioambient/websocket.py", line 226, in connect await self._sio.connect( File "/usr/local/lib/python3.10/site-packages/socketio/asyncio_client.py", line 109, in connect await self.eio.connect(url, headers=headers, File "/usr/local/lib/python3.10/site-packages/engineio/asyncio_client.py", line 111, in connect return await getattr(self, 'connect' + self.transports[0])( File "/usr/local/lib/python3.10/site-packages/engineio/asyncio_client.py", line 306, in _connect_websocket ws = await self.http.ws_connect( File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 779, in _ws_connect resp = await self.request( File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect return await fut asyncio.exceptions.CancelledError

bgulla commented 1 year ago

FWIW, I was having this same issue across different versions of home-assistant. Tried the "close out all your browsers" trick and it worked, it does seem that the api_key isnt commited with AWN until you move away from their page. wild.

issue-triage-workflows[bot] commented 11 months 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.

Gremlyn commented 11 months ago

Setting up a new HA install and trying to get this to work and am encountering the same invalid key problem. Not much to the logs other than what has already been reported. Home Assistant 2023.8.1 Supervisor 2023.08.dev0403 Frontend 20230802.0 - latest

SRF-Audio commented 8 months ago

Just did a migration from HA Core in a VM, to HAOS Supervised on bare metal, and I'm trying to get this integration up and running again, and having same issue as the others. Brand new API key created, closed the browser window and pasted from a text editor:

Logs UI:

Logger: homeassistant.components.ambient_station
Source: components/ambient_station/__init__.py:73
Integration: Ambient Weather Station (documentation, issues)
First occurred: 20:13:27 (35 occurrences)
Last logged: 20:55:54

Config entry failed: Connection error

And from the actual .log:

2023-10-10 20:57:14.567 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=<my full key>&transport=websocket&EIO=3
2023-10-10 20:57:19.575 ERROR (MainThread) [homeassistant.components.ambient_station] Config entry failed: Connection error
2023-10-10 20:58:15.818 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session

HA stats: Home Assistant 2023.10.1 Supervisor 2023.10.0 Operating System 10.5 Frontend 20231005.0 - latest

@bachya One thing I'm noticing...that api=1 value in the URL is unedited, and that is clearly not the key I entered. (I removed the applicationKey).

Is the value for api_key being correctly read from the frontend payload into the web socket url constructor? I took a look at the POST from dev tools, and the Payload has the correct values for:

{
api_key: ...,
app_key: ...
}

So, something is happening after the request hits the backend.

bachya commented 8 months ago

@bachya One thing I'm noticing...that api=1 value in the URL is unedited, and that is clearly not the key I entered. (I removed the applicationKey).

That is expected: the api query parameter refers to the API version, not the API key itself (source).


I still cannot reproduce this. I just spun up a fresh HASS 2023.10.3, generated a new app/API key pair in the Ambient Weather dashboard, and added it successfully:

CleanShot 2023-10-13 at 10 51 31

2023-10-13 10:49:16.517 INFO (SyncWorker_3) [homeassistant.loader] Loaded ambient_station from homeassistant.components.ambient_station
2023-10-13 10:49:16.553 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of aioambient==2023.04.0
2023-10-13 10:49:42.111 DEBUG (MainThread) [aioambient] Received data for devices: [{'macAddress': 'REDACTED', 'lastData': {'dateutc': 1697215740000, 'tempinf': 66.6, 'humidityin': 35, 'baromrelin': 29.879, 'baromabsin': 24.942, 'tempf': 50.4, 'humidity': 43, 'winddir': 30, 'windspeedmph': 4.5, 'windgustmph': 5.8, 'maxdailygust': 14.8, 'hourlyrainin': 0, 'eventrainin': 0, 'dailyrainin': 0, 'weeklyrainin': 0.051, 'monthlyrainin': 0.071, 'totalrainin': 70.669, 'solarradiation': 364.81, 'uv': 3, 'batt_co2': 1, 'feelsLike': 50.4, 'dewPoint': 28.76, 'feelsLikein': 66.6, 'dewPointin': 38.1, 'lastRain': '2023-10-12T19:15:00.000Z', 'tz': 'America/Denver', 'date': '2023-10-13T16:49:00.000Z'}, 'info': {'name': 'Side Yard', 'location': 'Home'}}]
2023-10-13 10:49:42.114 INFO (MainThread) [homeassistant.setup] Setting up ambient_station
2023-10-13 10:49:42.114 INFO (MainThread) [homeassistant.setup] Setup of domain ambient_station took 0.0 seconds
2023-10-13 10:49:42.118 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=REDACTED&transport=websocket&EIO=3
2023-10-13 10:49:42.782 INFO (MainThread) [aioambient] WebSocket connection accepted with {'sid': 'REDACTED', 'upgrades': [], 'pingInterval': 25000, 'pingTimeout': 20000}
2023-10-13 10:49:42.782 INFO (MainThread) [aioambient] Engine.IO connection established
2023-10-13 10:49:42.783 INFO (MainThread) [aioambient] Sending packet PING data None
2023-10-13 10:49:42.783 INFO (MainThread) [aioambient] Received packet MESSAGE data 0
2023-10-13 10:49:42.784 INFO (MainThread) [aioambient] Namespace / is connected
2023-10-13 10:49:42.784 INFO (MainThread) [aioambient] Emitting event "subscribe" [/]
2023-10-13 10:49:42.784 INFO (MainThread) [aioambient] Sending packet MESSAGE data 2["subscribe",{"apiKeys":["REDACTED"]}]
2023-10-13 10:49:42.784 INFO (MainThread) [aioambient] Watchdog triggered – sleeping for 900 seconds
2023-10-13 10:49:42.786 INFO (MainThread) [homeassistant.components.ambient_station] Connected to websocket
2023-10-13 10:49:43.347 INFO (MainThread) [aioambient] Received packet PONG data None
2023-10-13 10:49:43.347 INFO (MainThread) [aioambient] Received packet MESSAGE data 2["subscribed",{"devices":[{"macAddress":"REDACTED","lastData":{"dateutc":1697215740000,"tempinf":66.6,"humidityin":35,"baromrelin":29.879,"baromabsin":24.942,"tempf":50.4,"humidity":43,"winddir":30,"windspeedmph":4.5,"windgustmph":5.8,"maxdailygust":14.8,"hourlyrainin":0,"eventrainin":0,"dailyrainin":0,"weeklyrainin":0.051,"monthlyrainin":0.071,"totalrainin":70.669,"solarradiation":364.81,"uv":3,"batt_co2":1,"feelsLike":50.4,"dewPoint":28.76,"feelsLikein":66.6,"dewPointin":38.1,"lastRain":"2023-10-12T19:15:00.000Z","deviceId":"5c328e3bc4eac477f09b7dc1","tz":"America/Denver","date":"2023-10-13T16:49:00.000Z"},"info":{"name":"Side Yard","location":"Home"},"apiKey":"REDACTED"}],"method":"subscribe"}]
2023-10-13 10:49:43.348 INFO (MainThread) [aioambient] Received event "subscribed" [/]
2023-10-13 10:49:43.348 INFO (MainThread) [aioambient] Watchdog triggered – sleeping for 900 seconds
2023-10-13 10:49:43.348 DEBUG (MainThread) [homeassistant.components.ambient_station] New station subscription: {'devices': [{'macAddress': 'REDACTED', 'lastData': {'dateutc': 1697215740000, 'tempinf': 66.6, 'humidityin': 35, 'baromrelin': 29.879, 'baromabsin': 24.942, 'tempf': 50.4, 'humidity': 43, 'winddir': 30, 'windspeedmph': 4.5, 'windgustmph': 5.8, 'maxdailygust': 14.8, 'hourlyrainin': 0, 'eventrainin': 0, 'dailyrainin': 0, 'weeklyrainin': 0.051, 'monthlyrainin': 0.071, 'totalrainin': 70.669, 'solarradiation': 364.81, 'uv': 3, 'batt_co2': 1, 'feelsLike': 50.4, 'dewPoint': 28.76, 'feelsLikein': 66.6, 'dewPointin': 38.1, 'lastRain': '2023-10-12T19:15:00.000Z', 'deviceId': '5c328e3bc4eac477f09b7dc1', 'tz': 'America/Denver', 'date': '2023-10-13T16:49:00.000Z'}, 'info': {'name': 'Side Yard', 'location': 'Home'}, 'apiKey': 'REDACTED'}], 'method': 'subscribe'}
2023-10-13 10:49:43.364 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.ambient_station
2023-10-13 10:49:43.367 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_absolute_pressure
2023-10-13 10:49:43.369 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_relative_pressure
2023-10-13 10:49:43.369 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_daily_rain
2023-10-13 10:49:43.370 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_dew_point
2023-10-13 10:49:43.370 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_event_rain
2023-10-13 10:49:43.370 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_feels_like
2023-10-13 10:49:43.371 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_precipitation_intensity
2023-10-13 10:49:43.371 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_humidity
2023-10-13 10:49:43.372 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_humidity_indoor
2023-10-13 10:49:43.372 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_last_rain
2023-10-13 10:49:43.380 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_max_gust
2023-10-13 10:49:43.380 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_monthly_rain
2023-10-13 10:49:43.381 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_irradiance
2023-10-13 10:49:43.381 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_solar_rad_lx
2023-10-13 10:49:43.381 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_temperature
2023-10-13 10:49:43.381 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_inside_temperature
2023-10-13 10:49:43.381 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_lifetime_rain
2023-10-13 10:49:43.382 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_uv_index
2023-10-13 10:49:43.382 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_weekly_rain
2023-10-13 10:49:43.382 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_wind_direction
2023-10-13 10:49:43.382 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_wind_gust
2023-10-13 10:49:43.383 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.ambient_station entity: sensor.side_yard_wind_speed
2023-10-13 10:49:43.405 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.ambient_station
2023-10-13 10:49:43.406 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.ambient_station entity: binary_sensor.side_yard_carbon_dioxide_battery
2023-10-13 10:50:07.784 INFO (MainThread) [aioambient] Sending packet PING data None
2023-10-13 10:50:07.939 INFO (MainThread) [aioambient] Received packet PONG data None
2023-10-13 10:50:11.343 INFO (MainThread) [aioambient] Received packet MESSAGE data 2["data",{"dateutc":1697215800000,"tempinf":66.6,"humidityin":35,"baromrelin":29.876,"baromabsin":24.939,"tempf":50.4,"humidity":40,"winddir":32,"windspeedmph":3.6,"windgustmph":4.5,"maxdailygust":14.8,"hourlyrainin":0,"eventrainin":0,"dailyrainin":0,"weeklyrainin":0.051,"monthlyrainin":0.071,"totalrainin":70.669,"solarradiation":369.94,"uv":3,"batt_co2":1,"feelsLike":50.4,"dewPoint":27,"feelsLikein":66.6,"dewPointin":38.1,"lastRain":"2023-10-12T19:15:00.000Z","tz":"America/Denver","date":"2023-10-13T16:50:00.000Z","macAddress":"REDACTED"}]
2023-10-13 10:50:11.344 INFO (MainThread) [aioambient] Received event "data" [/]
2023-10-13 10:50:11.344 INFO (MainThread) [aioambient] Watchdog triggered – sleeping for 900 seconds
2023-10-13 10:50:11.344 DEBUG (MainThread) [homeassistant.components.ambient_station] New data received: {'dateutc': 1697215800000, 'tempinf': 66.6, 'humidityin': 35, 'baromrelin': 29.876, 'baromabsin': 24.939, 'tempf': 50.4, 'humidity': 40, 'winddir': 32, 'windspeedmph': 3.6, 'windgustmph': 4.5, 'maxdailygust': 14.8, 'hourlyrainin': 0, 'eventrainin': 0, 'dailyrainin': 0, 'weeklyrainin': 0.051, 'monthlyrainin': 0.071, 'totalrainin': 70.669, 'solarradiation': 369.94, 'uv': 3, 'batt_co2': 1, 'feelsLike': 50.4, 'dewPoint': 27, 'feelsLikein': 66.6, 'dewPointin': 38.1, 'lastRain': '2023-10-12T19:15:00.000Z', 'tz': 'America/Denver', 'date': '2023-10-13T16:50:00.000Z', 'macAddress': 'REDACTED'}
2023-10-13 10:50:32.786 INFO (MainThread) [aioambient] Sending packet PING data None
2023-10-13 10:50:32.854 INFO (MainThread) [aioambient] Received packet PONG data None
2023-10-13 10:50:57.788 INFO (MainThread) [aioambient] Sending packet PING data None
2023-10-13 10:50:57.865 INFO (MainThread) [aioambient] Received packet PONG data None
2023-10-13 10:51:22.790 INFO (MainThread) [aioambient] Sending packet PING data None
2023-10-13 10:51:22.878 INFO (MainThread) [aioambient] Received packet PONG data None
2023-10-13 10:51:37.308 INFO (MainThread) [aioambient] Sending packet CLOSE data None
2023-10-13 10:51:37.308 INFO (MainThread) [aioambient] Engine.IO connection dropped
2023-10-13 10:51:37.308 INFO (MainThread) [homeassistant.components.ambient_station] Disconnected from websocket
2023-10-13 10:51:37.310 ERROR (MainThread) [aioambient] packet queue is empty, aborting
2023-10-13 10:51:37.310 INFO (MainThread) [aioambient] Exiting write loop task
2023-10-13 10:51:37.311 INFO (MainThread) [aioambient] Exiting ping task
SRF-Audio commented 8 months ago

@bachya One thing I'm noticing...that api=1 value in the URL is unedited, and that is clearly not the key I entered. (I removed the applicationKey).

That is expected: the api query parameter refers to the API version, not the API key itself (source).

I still cannot reproduce this. I just spun up a fresh HASS 2023.10.3, generated a new app/API key pair in the Ambient Weather dashboard, and added it successfully:

Again, one variable in my case that may be at play was that I was previously using HA in Docker on my Synology. I exported a backup from the Docker instance, and have since migrated that backup into a bare metal install of HAOS Supervised on a MiniPC.

I'm not sure if there's configuration somewhere that may be causing an issue.

SRF-Audio commented 8 months ago

Did some more digging on this. Enabled debug logging, and found this when I got the invalid API key error:

2023-10-26 22:37:42.691 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139737531461440] <my-ip> (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36): Sending [{"id":96,"type":"result","success":true,"result":{"resources":{"component.ambient_station.config.abort.already_configured":"Service is already configured","component.ambient_station.config.error.invalid_key":"Invalid API key","component.ambient_station.config.error.no_devices":"No devices found in account","component.ambient_station.config.step.user.data.api_key":"API key","component.ambient_station.config.step.user.data.app_key":"Application Key","component.ambient_station.config.step.user.title":"Fill in your information"}}},{"id":97,"type":"result","success":true,"result":{"resources":{}}}] 2023-10-26 22:37:42.692 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139737531461440] <my-ip> (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36): Sending {"id":98,"type":"result","success":true,"result":{"resources":{"component.ambient_station.title":"Ambient Weather Station"}}}

So, my initial thought is that somewhere, it's still finding configuration from the old instance, even though I removed the integration. I'm gonna see if I can find out what's causing it to evaluate to "Service is already configured."

SRF-Audio commented 8 months ago

Ok, another clue: I ran grep -r -i -C 5 -e "ambient_station" -e "ecobee" /config/.storage/ (the two integrations giving me problems), and I found all of the the entity_id's in core.entity_registry and core.device_registry.

I'm removed those entities from the UI already, and they are nowhere to be found, except in these files. That could be why component.ambient_station.config.abort.already_configured":"Service is already configured" is happening.

SRF-Audio commented 8 months ago

So, I have spent days trying to solve this, to no avail. Extremely frustrating.

Best I can tell is that it's something specific to DNS resolution for bare metal HAOS installs, but that's just a guess. Some threads that were very similar to what I was experiencing:

It also might be something related to restoring a backup from a VM instance, into an HAOS bare metal instance, but that's conjecture on my part.

In my case, the nameserver was set correctly, and I was able to resolve addresses with NS Lookup. Also, HA correctly links to documentation, etc. It was just the Ecobee and Ambient Weather integrations that refused the API keys. I couldn't get any meaningful logs other than what I've already posted.

I even killed the config directory to try a fresh start, and that still didn't work.

I'm officially giving up on HAOS bare metal.

I moved back into my HAOS VM, and both Ambient Weather and Ecobee worked perfectly right away. I'll probably just install ProxMox on that miniPC I was going to use, and then use HAOS as a VM running on that.

louisc32578 commented 7 months ago

Well I was almost in tears when I just could not get the API key to work. Till I realized that when I copied the key , I fat finger 4 spaces before API key digit. TRASH in trash out. Operator a sleep at the wheel.

bschaefer22 commented 6 months ago

From what I notice when trying this is that when you copy the codes from the Ambient dashboard it had 3 extra lines of text when pasted into notepad. So for some reason their website is selecting additional text. As a result, I don't think you need to close the site first. It's just this selection issue when copying.

So make sure to paste it into a notepad/text editor first and then copy/paste that into the integration configuration.

codyc1515 commented 5 months ago

If this is a continuing issue copying from the Ambient dashboard, perhaps this integrations config flow could trim the input?

JonLaliberte commented 3 months ago

First time using AW, I was setting up a new ObserverIP and I ran into this problem. My AW account was brand new, device new. I created the API and Application keys and was getting this error.

When it happened I remembered reading the note above about the copy including extra chars so I did throw it into a text editor just to check - but the copies in my case were clean (no extra characters).

I saw this other note from above:

I recently had this issue as well. After you create the API/APP keys in the Ambient Weather Dashboard, copy them to a text file and close the Ambient Weather page. Then go into Home Assistant and add the integration.

It seems Ambient Weather does not actually save the APP/API keys until you close out.

And figured I'd give it a try. I reloaded the AW page and cancelled the current integration install. Then I tried again. This time it worked πŸ€·πŸ»β€β™‚οΈ

This may seem like a "me too", but I wanted to add a note because I saw a lot of posts earlier discussing whether it could be related to moved installs etc. I just figured a completely fresh install/device/account would be a good data point.

saschmit commented 2 months ago

I think the issue is real (and continuing, as I just hit this today), but the problem is on the AmbientWeather side -- it doesn't commit the keys until the browser navigates away from the API/App key page. It doesn't hide them (like some other API key generators), so there's no particular reason to save them off beforehand.

I think the Home Assistant action here is to document more clearly how to generate both keys (one of them is hidden behind a link instead of a button these days) and also document the workaround to get the keys to commit.

bachya commented 2 months ago

I think the issue is real (and continuing, as I just hit this today), but the problem is on the AmbientWeather side -- it doesn't commit the keys until the browser navigates away from the API/App key page. It doesn't hide them (like some other API key generators), so there's no particular reason to save them off beforehand.

I think the Home Assistant action here is to document more clearly how to generate both keys (one of them is hidden behind a link instead of a button these days) and also document the workaround to get the keys to commit.

I welcome PRs to update the docs.

chriskacerguis commented 1 month ago

I think the issue is real (and continuing, as I just hit this today), but the problem is on the AmbientWeather side -- it doesn't commit the keys until the browser navigates away from the API/App key page. It doesn't hide them (like some other API key generators), so there's no particular reason to save them off beforehand.

I think the Home Assistant action here is to document more clearly how to generate both keys (one of them is hidden behind a link instead of a button these days) and also document the workaround to get the keys to commit.

I'm not sure that I agree with that. I'm having the same problem. I have navigated away, closed browser windows (even rebooted my machine). I'm still having issues with the "Invalid API Key".