Closed wsguede closed 2 years ago
I do have the integration installed
More info from the HA logs
2022-01-28 13:36:32 ERROR (MainThread) [aiohttp.server] Error handling request
... bunch of awaits...
File "/config/custom_components/awnet_local/__init__.py", line 51, in async_handle_update
mac = format_mac(call.data.get('PASSKEY', None))
File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 131, in format_mac
if len(to_test) == 17 and to_test.count(":") == 5:
TypeError: object of type 'NoneType' has no len()
Looks like I may need some better sanitization on the MAC address for the integration. Can you double-check the format of the MAC address on your integration? If HA processed it properly on input, then it should have come out looking like this:
except that it will be your MAC separated by colons. I received the same 500 error from the add-on when I inputted a badly formatted MAC.
Also, what version of HA are you running?
yeah the mac address thats in the passkey is the same mac address i used in the local integration, which is the same mac address that is in my router.
ma:ca:dd:rs <--- not my mac address
E8:DB:84:00:00:00 <--- this is a better representation of my mac
the last 3 sets removed.
wondering if the C version sends data differently? (i have the b)
TypeError: object of type 'NoneType' has no len()
<-- makes me feel like call.data.get('PASSKEY', None)
is not returning something.
is data = body? it looks like my passkey is for sure in the query params. Dont know what gets sent in the body of the post though, so it could still be there.
how do i turn debug logs on?
Version | core-2021.12.10
// code
_LOGGER.error(f"Failed to send {payload_json} to {url} with headers {head}; {response.content}")
// log
Failed to send {} to http://supervisor/core/api/services/awnet_local/update with headers {'Authorization': 'Bearer superSecretToken', 'content-type': 'application/json'}; b'500 Internal Server Error\n\nServer got itself in trouble'
^ this also makes me feel like the payload failed to send actual data?
By default the awnet app has the Path as /data/report/
The app is NOT smart enough to know that it needs to add a ?
before the query params. SO you get a log that looks like
[28/Jan/2022 13:32:32] "GET /data/report/stationtype=AMBWeatherV4.3.2&PASSKEY=ma:ca:dd:rs...
When the code looks for the query params its probably looking for everything after the ?
.
As you can see there is no ?
Change the path in the awnet to ?
Doing /data/report?
probably works too as this code just asks for the query params and doesnt look at the path.
While this is in the DOCS.md file, I will update it to make it more clear since it's just a single '?' sitting there right now. Thanks for the extra info!
@tlskinneriv ah yes!
I thought I saw this requirement somewhere, but I couldnt remember where specifically? Normally the main readme page is the goto page; At least to link to more docs.
I did look at the awnet readme as well, but I dont think it has the link to docs.md either?
At the end of the day someone might bump into this issue, and come to the issues to find a solution, and we have it here. So thats a win. Thanks again for the support and the initial work you and @dancwilliams did with the project.
Hey First thanks for the work you and @dancwilliams have put into these integrations. Going to make everything nice and easy for many people in the future.
That said, I moved from @dancwilliams build to this build, and something seems to not be working. With his, i was getting just the 200's from the
/data/report/...
call in the logs.With this build I seem to be getting some 500's when the data is pushed to supervisor?
any thoughts?