apetrycki / daikinskyport

API for accessing a DaikinOne+ Thermostat
60 stars 27 forks source link

Trouble probing device #51

Closed gkd720 closed 1 year ago

gkd720 commented 1 year ago

I'm trying the actions under "probe the device" to get detailed thermostat info, but having trouble. I'm using python (system access token successfully gotten earlier) and doing:

47 headers = { 48 "Accept": "application/json", 49 "Authorization": "Bearer " + systemAccessToken 50 } 51 url="https://api.daikinskyport.com/deviceData/(myUUID)" 52 thermostatResponse=requests.get(url,headers=headers)

But this returns: {'message': 'Unauthorized'}

Any idea what I'm doing wrong? Is this still the right url/domain?

From Daikin's documentation, for a similar type of request, I see an url use of "https://integrator-api.daikinskyport.com/v1/devices/UUID", which has worked to get the system access token, a list of devices, and some basic thermostat data. Is the url "api.daikin......." (without the leading "integrator-") still supported? I had contacted Daikin email support about this problem, but they said "We do not have the last endpoint you listed.", which is the "api.daikin..." one. Thanks.

apetrycki commented 1 year ago

Others have had this problem and if you haven't created your skyport account, that is why. If you have, it may just not work yet. It seems to take a day or two. The integrator API is different from the one this integration uses. It was something Daikin released well after I created this integration by reverse engineering the app. The API used in the app is much more robust.

gkd720 commented 1 year ago

Thanks, no, I did not create a skyport account so that explains it. I only have credentials for the phone app. But just the fact that I can get home thermostat info from a daikin url is a little creepy, but OK, I guess telling someone my setpoints aren't a real security concern. Anyway, your "reverse engineering the app" intrigued me, so I started poking around with Wireshark, monitoring wifi traffic to/from the thermostat. I did a ping from a desktop computer, and see that traffic. But I did a set point change from the "Daikin Home App" on my Android phone and see nothing. How else might the app be communicating with the thermostat? Even if it went through a daikin site, wouldn't I see something into the thermostat? Thanks for any insights.

apetrycki commented 1 year ago

All requests for your thermostat should require an access token. You shouldn't get a response if you don't provide the token. The token is what protects your data.

Wireshark won't really tell you anything. All the data is encrypted. I sent the app through a proxy server that would act as a man-in-the-middle and decrypt the data. The app communicates with their cloud service and the thermostat does as well. If you have Wireshark set up properly to sniff your Wi-Fi, you should see packets go to the cloud from the app and then from the cloud to the thermostat.

molohov commented 1 year ago

I'm having this issue too.

I can successfully request the access token. When I try to do:

curl --location --request GET "https://api.daikinskyport.com/devices" \ --header "Accept: application/json" \ --header "Authorization: Bearer "

I get: {"message":"Unauthorized"}

I had only created a Daikin One account on the app before this. I tried creating a Skyport account but it has a completely different login and there is no way there to add the Daikin One thermostat.

apetrycki commented 1 year ago

I never had to do it, but from my understanding, you just have to create the account with the same info as your Daikin One app and eventually it'll work. It can take a couple days for whatever reason.

molohov commented 1 year ago

I see, I'll check again in a few days. Why would I be able to retrieve an access token using the Daikin One credentials but still need to create a Daikin Skyport account?

molohov commented 1 year ago

Can confirm the data is showing up now after letting my identical Skyport account propagate. This sounds like it should be documented in the readme?

apetrycki commented 1 year ago

Yeah, good point. If you can do a pull request documenting what you did, I'll merge it in. I've never had to do it, so I don't know the exact process.

My guess is the skyport API is a legacy way of accessing it and they made changes since I installed my thermostat. There's probably a second URL they use now that uses a different account to authenticate, but the thermostat checks for the skyport one first. It's possible rebooting the thermostat would fix the lag between creating the account and it working. It'd be interesting to test.