Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTXM15R5V1B and FTXM20R5V1B : New API? #123

Open
jptoucas opened this issue Feb 19, 2021 · 218 comments
Open

CTXM15R5V1B and FTXM20R5V1B : New API? #123

jptoucas opened this issue Feb 19, 2021 · 218 comments
Labels
enhancement New feature or request

Comments

@jptoucas
Copy link

Hello,

I have a CTXM15R5V1B and FTXM20R5V1B units, the pages called by the plugin doesn't exists on those units:

ERROR: Queued request to http://192.168.1.147/common/basic_info returned error Error: Not Found
at Request.callback (/homebridge/node_modules/homebridge-daikin-local/node_modules/superagent/src/node/index.js:879:15)
at IncomingMessage. (/homebridge/node_modules/homebridge-daikin-local/node_modules/superagent/src/node/index.js:1130:18)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
status: 404,
response: [Response],
retries: 0

I tried the url http://192.168.1.147/aircon/get_model_info and I got this message :

Page Not Found
/aircon/get_model_info
And with http://192.168.1.147/skyfi/aircon/get_model_info :

Page Not Found
/skyfi/aircon/get_model_info
I have another unit (FTXA50A2V1BW) that is working well with the plugin.

The wifi controler is new, the BRP069C4x, It looks like there is a full new api to discuss with it.
I started to catch https calls from the Daikin Residential Controler : from France, we need to discuss with https://api.prod.unicloud.edc.dknadmin.be 4

First request on https://api.prod.unicloud.edc.dknadmin.be/v1/info 6
Second request on ***/v1/gateway-devices

Dont know yet how is done the authentication, I don’t know if there is a way to connect locally to each Daikin units ..

That would be great if we could get the compatibility of new units with homebridge, I will help if my skills are enough on this topic !

@cbrandlehner
Copy link
Owner

Hi @jptoucas
Unfortunately your device is obviously using a different API.
I am the author of this plugin but do not have access to a new device with the new / other API. Without access I see no way to reverse engineer the API.

If you can find out how your device works and you can provide a list of working URLs, preferred in CURL format, there is a chance that API can be added too.

@cbrandlehner cbrandlehner added the enhancement New feature or request label Feb 21, 2021
@jptoucas
Copy link
Author

Thanks for your feedback.
I can try to catch calls done by the iOS app to the Daikin cloud, and find out what is needed. That could be better to catch call between the Daikin cloud and my unit, but I have no idea how to do it. Witch approach would you have in my situation?

@rjcarlson49
Copy link

This may be that API your are dealing with:

https://backend.daikincomfort.com/docs/default-source/product-documents/residential/manuals/othermanual/im-dknapi.pdf?sfvrsn=b0e02426_6

@jptoucas
Copy link
Author

This may be that API your are dealing with:

https://backend.daikincomfort.com/docs/default-source/product-documents/residential/manuals/othermanual/im-dknapi.pdf?sfvrsn=b0e02426_6

Yes it looks like to be the right one !
I will check my iOS traces to confirm that ASAP

@rjcarlson49
Copy link

I have a plan to do a plugin for that API, but I have to finish another project first, an iOS app.

I can't believe how bad the DKN app is. It's an embarrassment.

@jptoucas
Copy link
Author

I agree, the app is far from perfect :(
I looked at a smart Ir remote but no states feedback is possible with it ...
I’m glad you planned to work an a plug-in for this API, I’m not a developer but I can help if necessary in many ways if needed (tests, catch traces,...)

@vanesp
Copy link

vanesp commented Feb 22, 2021

I’ve run into the same problem...my brand new Daikins only talk the new protocol. Shit.
I wanted to bind it to my domotica system. I’m in the Netherlands and trying to connect to Oauth2.0 but neither the end point in the docs nor the one you list above works for me...

@vanesp
Copy link

vanesp commented Feb 22, 2021

@jptoucas what is the full endpoint for the first call to authenticate?

@vanesp
Copy link

vanesp commented Feb 22, 2021

Oh by the way... if you look at the webpage of your WiFi controller, it looks like it’s got MQTT built in... that would be really interesting

@jptoucas
Copy link
Author

The first request I see from iOS Is a POST to https://sentry.io/api/1860051/envelope/ then a GET with https://api.prod.unicloud.edc.dknadmin.be/v1/info
I have to check at the dnk api doc to understand how is done the authentication, it looks that it has to be done in two steps to get a token.

The webpage shows FreeRTOS and mention "Eclipse Paho MQTT C/C++ client for Embedded platforms" : Only the port 80 is listening on my unit, I'm not sure there is MQTT capability here

@vanesp
Copy link

vanesp commented Feb 24, 2021

Interesting...

I've put this in a bit of code, conform the procedure listed in the API document above... but now with the URL you indicated:

import requests # pip install requests
url = 'https://sentry.io/api/1860051/envelope/'
headers = {
    'Accept': 'application/json',
    'Content-type': 'application/json',
}
payload = {'email':'[email protected]', 'password':'secret'}
r = requests.post(url, headers=headers, data=payload)
print(r.json())

I've used the e-mail address and password I'm using to authenticate the Daikin Residential Controller. The response I get makes a little more sense than with the Daikin URL from the document:

{'detail': 'missing authorization information'}

However, it looks like the authentication process does not conform with the API document.

@vanesp
Copy link

vanesp commented Feb 24, 2021

The Sentry also supports an OAuth process...

https://docs.sentry.io/product/integrations/integration-platform/

@vanesp
Copy link

vanesp commented Feb 24, 2021

If I run the same code with a link to: https://api.prod.unicloud.edc.dknadmin.be/v1/info then the response is:

{'code': 'UNAUTHORIZED', 'message': 'The given token is invalid. Check the value of the Authorization HTTP request header.'}

which makes sense because I do not yet have a token.

@rospogrigio
Copy link

Hi, I also have a pair of devices with the BRP069C4x adapter, I'm following this thread and open to do testing if needed.
Thank you

@jptoucas
Copy link
Author

jptoucas commented Feb 26, 2021

I will do some new attempts on my side, there is a screenshot of the full trace:
Capture d’écran 2021-02-26 à 23 12 16

@jptoucas
Copy link
Author

jptoucas commented Feb 26, 2021

To complete my last message:
During my first try, I missed a request before the sentry.io, sorry for that.
The first request, as you can see on the screenshot, is a GET to api.prod.unicloud.edc.dknadmin.be

There is the curl command :
curl -H 'Host: api.prod.unicloud.edc.dknadmin.be' -H 'accept: application/json' -H 'content-type: application/json' -H 'user-agent: Daikin/1.7.0.4696 CFNetwork/1220.1 Darwin/20.3.0' -H 'x-api-key: YYYYYY' -H 'if-none-match: XXXXXXX' -H 'accept-language: fr-fr' -H 'authorization: Bearer ZZZZZ' --compressed 'https://api.prod.unicloud.edc.dknadmin.be/v1/info'

There is a bearer token (replaced by ZZZZ) , an api-key (replaced by yyyy) and another string if-none-match (replaced by XXXX, it has to be different for another calls)

@jptoucas
Copy link
Author

jptoucas commented Feb 26, 2021

I also catch the first login traces in the Daikin Residential Controler:
They use SAML to authenticate our user/pwd, the bearer is returned by the POST on daikin-unicloud-prod.auth.eu-west-1.amazoncognito.com//oauth2/token
I'm definitely not skilled enough to do the plugin my self !

Capture d’écran 2021-02-26 à 23 30 30

@vanesp
Copy link

vanesp commented Feb 27, 2021

I tried to log the same with Charles Proxy however when I did I'm sure I must be doing something wrong. The Daikin app complains there is no network, and it won't find my airconditioning units. So I have no sensible values for XXXX, YYYY and ZZZ above. Could you perhaps mail me them at vanes.peter at google.com so that I can insert them into code and see if I can get a valid token.

We are getting closer:
{'callId': '6ed15725c3ba49778e25f54332a814df', 'errorCode': 400093, 'errorDetails': 'Missing required parameter: ApiKey', 'errorMessage': 'Invalid ApiKey parameter', 'apiVersion': 2, 'statusCode': 400, 'statusReason': 'Bad Request', 'time': '2021-02-27T10:59:54.382Z'}

Then we also need the exact payload of the PUT and GET to daikin-unicloud... and api.prod.unicloud... as I think that is where the interaction is happening!

@jptoucas
Copy link
Author

jptoucas commented Feb 28, 2021

Hi, you need to enable SSL proxying in Charles, for each target hosts. I followed this tutorial : https://www.raywenderlich.com/1827524-charles-proxy-tutorial-for-ios#toc-anchor-004

I had the same issue in the iOS App (don’t forget to enable the full trust of the Charles certificate in your iOS devise in Settings/General/Informations/certificate settings, it was not on the tutorial)

@Apollon77
Copy link

There is a bearer token (replaced by ZZZZ) , an api-key (replaced by yyyy) and another string if-none-match (replaced by XXXX, it has to be different for another calls)

The XXXX should be irrelevant and you could be able to remove that header. it is just the ETAG from last call to allow server side caching.

And the "bearer token" should have come from an earlier login into the cloud account? So maybe the best idea ois to try a "complete fresh app install". maybe I can try next days with my app, i never logged in into that cloud account, maybe so I can get a fresh capture

@Apollon77
Copy link

Maybe also @rjcarlson49 or @LostInTheTrees ... I saw you created some time ago ca new homebrudget fork with a name like "cloud" :-) maybe you also have some notes ....

@ImHereBecauseOfNewDaikinAPI
Copy link

ImHereBecauseOfNewDaikinAPI commented Mar 12, 2021

Hi guys,

I was following up this topic since I got a brand new Daikin HVAC coming with the new BRP069C4x controller. Unfortunately I cannot add it from my Home Assitant server because of the brand new cloud API using AWS.

I have done some tests, catching some traffic, and I was able to catch the request to obtain a bearer token composed of an id_token, an access_token, a refresh_token and an default expiration of 3600.

I've also catched something that is probably the whole configuration of my unit by using this URL https://api.prod.unicloud.edc.dknadmin.be/v1/gateway-devices

And, last but not least I was barely able to replay a ON action and a OFF action with a valid authorization from my laptop by using this URL https://api.prod.unicloud.edc.dknadmin.be/v1/gateway-devices/7f9245ed-26a0-4a01-ba61-5fb2145df510/management-points/climateControl/characteristics/onOffMode with this kind of argument:
{"value":"on"} - {"value":"off"}.

I'm not copy/pasting things here since I'm not sure what should be obfuscated. I'm not a dev and I don't have skills regarding API but I'm just here to help if somebody wants to go a little bit further.
I'll also take some time this week-end to do things on my side, I'll keep you in touch but it seems that we definitely could manage the unit if we have a valid token. Unfortunately nothing could be sent locally... Everything will goes through the AWS cloud. BTW I'm also working on a exhaustive URL and protocol list to restrict the outgoing traffic from the Daikin unit. I'll also keep you in touch with that.

Thanks,

@Apollon77
Copy link

I have done some tests, catching some traffic, and I was able to catch the request to obtain a bearer token composed of an id_token, an access_token, a refresh_token and an default expiration of 3600.

Were you also able to get the call to get the access/refresh tokens before? (normally happens when you login into the cloud account)

If you like (and are ok with someone else looking at the traffic I would be happy to get your infos via email (not that public) to [email protected] (and to tell why I ask that ... I develop the nodejs daikin lib daikin-controller

@ImHereBecauseOfNewDaikinAPI
Copy link

ImHereBecauseOfNewDaikinAPI commented Mar 12, 2021

That's not clear at this point but I'll sent you required info tonight since I'm not focused at the moment I'm just doing things in background.

I was also able to retrieve new access token by using the refresh token and send commands to the unit like changing the temperature with the new generated access token succesfully.

@vanesp
Copy link

vanesp commented Mar 12, 2021

I was also able to retrieve new access token by using the refresh token and send commands to the unit like changing the temperature with the new generated access token.

That's really good, because that is what is needed to keep this going. And as @Apollon77 says, we need to know how to start up the exchange for a particular device.

@rospogrigio
Copy link

Hi, I would like to test my device as well, may I ask you some questions? How can I signup for a cloud account? Which is the URL I should refer to?
Great job guys, something is moving here! 👍

@Apollon77
Copy link

Apollon77 commented Mar 12, 2021

In my eyes it is all about getting the app traffic.
So ideally utilize Charles Proxy, setup for ssl sniffing and certs in the mobile device.

Then ideally uninstall the app and install again and then gettraffic started with the veeery first start (because some apps register themself on first start and get an id or such). ANd then regioster the new adapter and then wee see what happens there.

I'm also at that process right now with one other user, but also here the "startpoint" is missing ... lets see :-)
but yes it incorporates trust to us, so I only excahnge that via email.

When we then understood it we can make it public (so not data but "how to do it") :-)

@rjcarlson49
Copy link

Maybe also @rjcarlson49 or @LostInTheTrees ... I saw you created some time ago ca new homebrudget fork with a name like "cloud" :-) maybe you also have some notes ....

Those are both me. I have not gotten to this project yet. I did another plugin first since this one will be a lot more complicated. I am also working on an unrelated iOS app that is almost done. I suspect I'll start this one in about a month.

I have 6 Daikin Vista indoor units that mount in the ceiling. They connect to 2 compressors outdoors. Having lived with them awhile I have learned a lot. First, I think their controls are godawful bad. The app they made is pathetic, so I am dying to get them into Homekit so I have decent control. For just one example, we cannot get them to heat unless all three indoor units on a compressor are set to identical settings and then cycled off then on. Even then, one of the systems will not heat.

@rjcarlson49
Copy link

I'm not sure why you think you need to capture the app traffic. The API doc looked pretty good to me. My plan was to get a good OAUTH2 package and let that do the login. Then once the security is taken care of, the API should define how to control the devices.

I've done a lot of wifi and ethernet capturing in my life and when encryption is happening it's quite difficult. I would use it only as a last resort.

@revk
Copy link

revk commented Apr 2, 2022

Thanks. This morning I have managed to work out most of the protocol used by the BRP069C41 to talk to the main unit (certainly the main temperature and mode controls), and so am working on a replacement unit. Hopefully it is similar protocol to the other new WiFi units. One idea would be to make it have the same URLs on it as the older Daikin WiFi modules - that should not be too hard. And also add MQTT and other stuff. I have documented what I have worked out so far: https://github.com/revk/ESP32-Daikin/raw/main/Daikin.pages

This is proposed circuit board (well, it will be this size anyway, needs a couple of FETs adding).

FPVhCi4XwAcpOw8

@rospogrigio
Copy link

Impressive job @revk !! Actually somebody has found some local endpoints but the search didn't get far, maybe there could be something more to try but who knows. You may want to have a look at these two threads:
https://community.home-assistant.io/t/daikin-ac-integration-brp069c4x/270936/284
https://community.home-assistant.io/t/daikin-airconditioning-wifi-module/142555/73

Nice job for the ESP adapter, how much does it cost to have it prototyped?

@revk
Copy link

revk commented Apr 2, 2022

I'll get a batch of 10 boards to start, and a stencil, probably a few pounds a board, and then a few pounds of components. Nothing that expensive on there.

@revk
Copy link

revk commented Apr 2, 2022

I have a board which is close enough to play with - it is technically 3.3V, but is a good proof of concept. It works!

It has taken me all day but I can now turn my aircon on/off, set temp, mode, fan speed, using my new WiFi module.
Now for the hard part - making it pretty :-)

FPWAMR7X0AQJMNg

@Marfre888
Copy link

now after @Apollon77 found a way to get the needed Token (without proxy setup) to be able to talk with the Daikin 2020+ Wifi Moduls (Cloud based) that are in more or less all new devices (also my 4x FTXM) Is it possible to support them also in your homebridge plugin?

Here is a link how to get the token: https://github.com/Apollon77/daikin-controller-cloud And here a link to an implementation of this new "cloud Api" as example for homeassistant https://github.com/rospogrigio/daikin_residential

@cbrandlehner: I hope this could help to support them also in HomeBridge Plugin soon...

misc2000

Hi,

I have managed to get a token using Apollon77's method, however, I'm at an end on what to do next.

Does the homebridge pluggin support these tokens? How can I go about making it work through homebridge? Any help would be greatly appreciated. I understand this isn't the local method everyone was hoping for (me included) but it is at least a good start and gets these devices working in Homekit.

M

@Apollon77
Copy link

hey all, I got a report that since an app update yesterday the API is no longer working and produces an Error 400 ... anyone else having this issue? Are any more details available? Else we need a new "traffic sniffing" from the app

@bartjanisse
Copy link

bartjanisse commented Apr 28, 2022

I’ve got the same error. But the data seems te be loaded also. So I first get the data from my 3 daikin devices and then I get the 400

0C1EBB1C-24C9-4E8C-B901-100406FB2B3B

@tbrichant
Copy link

now after @Apollon77 found a way to get the needed Token (without proxy setup) to be able to talk with the Daikin 2020+ Wifi Moduls (Cloud based) that are in more or less all new devices (also my 4x FTXM) Is it possible to support them also in your homebridge plugin?
Here is a link how to get the token: https://github.com/Apollon77/daikin-controller-cloud And here a link to an implementation of this new "cloud Api" as example for homeassistant https://github.com/rospogrigio/daikin_residential
@cbrandlehner: I hope this could help to support them also in HomeBridge Plugin soon...
misc2000

Hi,

I have managed to get a token using Apollon77's method, however, I'm at an end on what to do next.

Does the homebridge pluggin support these tokens? How can I go about making it work through homebridge? Any help would be greatly appreciated. I understand this isn't the local method everyone was hoping for (me included) but it is at least a good start and gets these devices working in Homekit.

M

Any idea on how we can use this method with homebridge ?

@Apollon77
Copy link

@bartjanisse And which request got that error? tried with a new token?

@Apollon77
Copy link

One feedback was that the old tokens seems to have issues ... so people need to regenerate the token

@bartjanisse
Copy link

The new token did the trick. I didn't needed a new one for such a long time I was forgotten about it completely.

Thanks for the feedback!

@edgarfroes
Copy link

edgarfroes commented May 3, 2022

Hey everyone. I was redirected here from #207, but it was for the FTHP09Q5VL model. Does the solution you guys are implementing work for this model?

@rospogrigio
Copy link

Hey everyone. I was redirected here from #207, but it was for the FTHP09Q5VL model. Does the solution you guys are implementing work for this model?

No idea, try and see if it works... cheers

@JeroenVdb
Copy link

JeroenVdb commented May 4, 2022

I'm creating a basic Homebridge plugin for Daikin cloud devices: https://github.com/JeroenVdb/homebridge-daikin-cloud
The plugin uses @Apollon77 daikin-controller-cloud package.

I'll try to publish this ASAP but I have some problems with my npmjs account.

Remarks:

  • First of all: only tested on my devices, listed in the readme.
  • this is the first time I create a Homebridge plugin, so might be missing some stuff or doing things wrong/suboptimal, feedback welcome.
  • I thought of Pull Requesting this into this Homebridge plugin but that would mean a great refactor at first sight, like to validate if it works first and decide on this later.

@JeroenVdb
Copy link

You can try it out: https://www.npmjs.com/package/homebridge-daikin-cloud

@Apollon77
Copy link

Ok, I think we can close here too or?

Hoembridge plugin exists, library exists, (ioBroker adater exists too) (and Home-Assistant is also done) ... :-)

@jptoucas
Copy link
Author

jptoucas commented Jun 6, 2022

Thanks guys for your work!!!!!

@jptoucas
Copy link
Author

jptoucas commented Jun 6, 2022

You can try it out: https://www.npmjs.com/package/homebridge-daikin-cloud

It’s working well to with BRP069B4x 👍🏻👍🏻

@edgarfroes
Copy link

@cbrandlehner as per discussed on this issue, the solution above using the homebridge-daikin-cloud plugin does not work for my Daikin AC model FTHP09Q5VL. I suppose it's a different type of AC that Daiking sent us here in Brazil, where it has its own cloud service called Daikin Smart AC Brasil.

Any updates on this?

@cbrandlehner
Copy link
Owner

@edgarfroes I do not own one of these devices so I can not help with testing or coding. My devices are old ones that work without cloud, https and without UUID.
The code to support these devices was contributed by the community.

@Apollon77
Copy link

@edgarfroes What mobile app do you use in brazil? Is it also the "Onecta App" or something else?

In fact it would require exact infos about which app and such and access credentials of such an account to check out whats exactly behind it (and obviously time to do that)

@edgarfroes
Copy link

edgarfroes commented Nov 9, 2022

I use these apps:

Play Store (Android)
App Store (iOS)

They can be available in certain countries only, but I'm not sure.

Here's their website, in Brazilian Portuguese: https://www.daikin.com.br/conectividade-app-smart-ac

Edit: my model also works with Google Assistant and Alexa, and the response is so fast that I assume that they're sending commands via the network, but I'm not sure.

CC @cbrandlehner @Apollon77

@edgarfroes
Copy link

I'm also available anytime to debug something if needed, chat or have a call, just ping me here.

@Apollon77
Copy link

@edgarfroes I think a separate issue is the best to not mix stuff. In general we would need a mobile app trace. This could e done by "Charles Proxy". Set that up on your PC, register and activate the right SSL Root Cert in the phone (see https://www.charlesproxy.com/documentation/using-charles/ssl-certificates/), download from there, set up proxy in your phone to point to charles.

then ideally uninstall the app and install again.

Then activate the proxy and startup the app, login into your account and interact with your devices ... in chalres you should see GET and POST calls ... if you only see CONNECT then ssl is not setup correctly - fix that and repeat!! Then save that session and send me the file to [email protected] and I can have a nlook to see if it is the same but just different servers or if it is something completely new

@ttimpe
Copy link

ttimpe commented Jan 31, 2023

Is there no local API for these controllers at all? Or have we just not figured out how it works?

@MAFFPT
Copy link

MAFFPT commented Jan 1, 2025

I'm a Hubitat user, not HA, but I'd like to try to help you guys. It seems that there's a HA integration - check it out:

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

Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests