galletn / iaqualink

Home Assistant Iaqualink Vacuums Robots
8 stars 1 forks source link

Authorization header requires 'Credential' parameter #4

Open bertocea85 opened 1 year ago

bertocea85 commented 1 year ago

when I make a POST to https://prod.zodiac-io.com/devices/v2/xxxxxx/shadow it returns the following error:

Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header.

With mitm proxy I see that it does a GET against https://r-api.iaqualink.net/v2/devices.json?user_id=xxx&signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&timestamp=1683216063

any idea? maybe it does a calculation of the signature and timestamp?

galletn commented 1 year ago

when do you get this? when running the integration or using postman?

bertocea85 commented 1 year ago

in both. Both in Home assistant and through postman. Home Assistant: image

bertocea85 commented 1 year ago

this is mitm's capture request image Response image

galletn commented 1 year ago

can you confirm in postman you send it like this: (it might be that your robot does not support this API and we need to find another one for you. What model of robot do you use?

image

galletn commented 1 year ago

this is mitm's capture request image Response image

so the MITM is when you use the app rigth? seems that you are using V2 and that is the issue with you ...

bertocea85 commented 1 year ago

Puede confirmar en Postman que lo envía así: (puede ser que su robot no admita esta API y necesitemos encontrar otra para usted. ¿Qué modelo de robot utilizas?

imagen

Vortex OV5490 IQ ZODIAC Mi captura de postman, image

bertocea85 commented 1 year ago

Esta es la respuesta de solicitud imagen de captura de mitm imagen

así que el MITM es cuando usas la aplicación derecho? parece que estás usando V2 y ese es el problema contigo ...

Correct, it is the traffic captured with mitm when using the iaqulink application for IOS.

bertocea85 commented 1 year ago

then, the next one in mitm is this one image and this is Response image

galletn commented 1 year ago

the timestamp is just calculated as you can take from this site: https://current-timestamp.com/#result

but the signature one ... does it correspond to anything you get back from the login api?

galletn commented 1 year ago

good to see you got the control traces too, that way we are sure what we can expect it to work. I'll try to add these too, but I would like to help you out on fixing the basics first.

For me and the others it seems to work, so it must be your robot that goes to the V2 that is a little different that we must tackle.

bertocea85 commented 1 year ago

I have already looked to see if it was a login value. there is nothing similar. in each call it uses a different signature and timestamp. then it does a get of the device to see the status. image post 500 is when the device is offline

bertocea85 commented 1 year ago

taking your code and testing it in visual studio, this is the answer. Modifying the "Shadow" by values of the API here https://github.com/tekkamanendless/iaqualink, I get different values image

galletn commented 1 year ago

it seems that its using Google API's ... so after a little round of google:

https://developers.google.com/maps/documentation/maps-static/digital-signature#generate-signed-request

I'm not sure what values to use though to make this work ...

so your device is not supporting the shadow API right ... ? it says it does not belong to you when you use another value?

galletn commented 1 year ago

the good news is I managed to get the stop/start command working thanks to your traces ... the bad news is ...it always returns offline while it is online ...

galletn commented 1 year ago

image

image

image

galletn commented 1 year ago

after looking into the traces I see that I have the same behaviour as ppastur, it switches to websocket, so your robot seems to have total different approach ... will need other tactics...

ppastur commented 1 year ago

image

image

image

@galletn do you want me to try the same to see if I get the same issue with it returning offline?

ppastur commented 1 year ago

the timestamp is just calculated as you can take from this site: https://current-timestamp.com/#result

but the signature one ... does it correspond to anything you get back from the login api?

Did you do that via websocket? if so, perhaps we didn't leave the socket open long enough to receive the stream showing updates. My trace seemed to show plenty of updates from the device?? just a random thought?

galletn commented 1 year ago

@galletn do you want me to try the same to see if I get the same issue with it returning offline?

yes might be handy to know if you get the same results

ppastur commented 1 year ago

@galletn do you want me to try the same to see if I get the same issue with it returning offline?

yes might be handy to know if you get the same results

Can you send me steps to reproduce - perhaps postman collection or code to run?

bertocea85 commented 1 year ago

image image image

@galletn do you want me to try the same to see if I get the same issue with it returning offline? @galletn @ppastur one question guys, where do you get the value for "Authorization"?

ppastur commented 1 year ago

@bertocea85 , authorization for me is the IdToken obtained in the post login

bertocea85 commented 1 year ago

@bertocea85 , authorization for me is the IdToken obtained in the post login

Thanks!!!!

galletn commented 1 month ago

@bertocea85 still having issues with the latest release?

bertocea85 commented 1 month ago

@galletn hello!! Sorry I've been away for a few days. Now with the latest update, I see the entity and I see the buttons to start cleaning and stop, but it gives an error in the call to the service.

image

Looking at the logs I see the following

Registrar: homeassistant.helpers.entity Source: helpers/entity.py:944 First occurred: 12:19:11 (59 occurrences) Last login: 13:17:10

Update for vacuum.robot_piscina fails Traceback (most recent call last): File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut ^^^^^^^^^ File "/config/custom_components/iaqualinkRobots/vacuum.py", line 404, in get_device_status message = await websocket.receive() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 244, in receive msg = await self._reader.read() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 681, in read return await super().read() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read await self._waiter asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1296, in async_device_update await self.async_update() File "/config/custom_components/iaqualinkRobots/vacuum.py", line 254, in async_update data = await asyncio.wait_for(self.get_device_status(request), timeout=30) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/tasks.py", line 519, in wait_for async with timeouts.timeout(timeout): File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in aexit raise TimeoutError from exc_val TimeoutError

galletn commented 3 weeks ago

@bertocea85 can you maybe change your password and send me over your credentials so that I can have a look? you can send them over to nicolas.gallet@skynet.be if you are willing. Thanks!

bertocea85 commented 2 weeks ago

@galletn Hi! Sure! I just sent you an email with the details. Thanks for your help!

galletn commented 2 weeks ago

@bertocea85 okay so I had a look and indeed your robot uses other api's as it is another device type. Can you have your robot being online? then I can see what happens when it is there...

image
galletn commented 2 weeks ago

the issue will be that it has very different behaviour then the other robots, as we can get the status it had previously even when its offline... so I also will need to think on how to handle that part ...

bertocea85 commented 2 weeks ago

hello @galletn !! Yes, I can put it in online mode, next Monday I will start it, I am not there right now to be able to turn it on

Thanks for your time

bertocea85 commented 1 week ago

@galletn , is online now

galletn commented 1 week ago

@bertocea85 okay so took some first traces, I'll keep you posted once I have a first test version.

It will probably just be to report if its running yes/no, stop start & lift will be supportable, but I don't see sensor data nor in the app nor in the returns of the calls so it will be more basic info compared to the other robot models.

bertocea85 commented 1 week ago

hello! @galletn Can I help you with anything else? Do you need any information or proof?

Thank you!

galletn commented 1 week ago

hi @bertocea85, can you leave the robot in the pool tonight? I would be able to continue my work on it.

So far what you could already test if it is correctly online/offline.

I'll upload the code in a jiffy in a new branch that supports the i2drobot.

So far the code here runs fine!

tonight I plan to create the stop start and get the status idle/running correctly, but for that I would prefer your robot to be for sure in the pool 😄

image

bertocea85 commented 1 week ago

Spectacular!!! Thank you for your time and dedication. Yes, the robot is currently in the water and online, there is no plan to take it out, hahaha

galletn commented 1 week ago

@bertocea85 last update of the code now supports stop start on your robot, the time remaining and lift will be next! feel free to test already! https://github.com/galletn/iaqualink/tree/galletn-patch-4

bertocea85 commented 1 week ago

hello!!

I have tested the code and it works perfectly!!! I can turn it on/off and see if it's cleaned.

Thank you @galletn

galletn commented 1 week ago

Excellent! I'll see what more I can do, but might be a busy week so depending on my schedule I'll add more functionality.

galletn commented 1 week ago

@bertocea85 can you confirm all is okay with the robot 😄 tested the return to base function and want to make sure it's fine before I test the time remaining while cleaning now.

I just updated the code, switching modes and getting the robot out of the water should work.

bertocea85 commented 6 days ago

@galletn hello! Yes, the robot is fine and works perfectly!

galletn commented 6 days ago

great! I'm away for one week, upon my return I'll reach out again to continue the work on this!