Daikin One integration

I see this post from @thebearmay :[DEPRECATED] Daikin OnePlus Thermostat Legacy Systems [Incompatible with New API]

It says "deprecated". However, if I install the 2 Groovy scripts directly from GitHub, will they still work, or am I out of luck? Thanks.

See the part where it says: "Incompatible with New API" ?

I'm thinking it means what it says. That the code no longer matches what Daikin supports.

That’s what I was afraid of. Hopefully, the developer @thebearmay can comment on this, and hopefully they are working on updating it? I see relatively recent checkins on GitHub, so wondering.

Last time I checked this code no longer allowed control of the device, and the new API was behind a pay wall.

Rats! Thanks for the info. I guess I am out of luck on this one!

It looks like things have changed - Daiken has a new API and it's free to use. I modified the driver from @thebearmay to make this new driver that seems to work.

Unfortuantly, the integration token is super long (1700 chars) and hubitat won't let me use preferences, so you have to modify the code in the GIST before you load it. There are three spots you need to update - API Key, your email, and the integrator token. Instructions for how to get them are here: Daikin One Open API - Documentation

I'm sure there is a better way to do this, but this is what I have! :slight_smile:

What was the issue with trying to add the token as a preference? Did it complain about the length or truncate it or ???

The hub just gave my a 500 screen when I tried to run any of the functionality of the device. The only way I discovered to fix it was remove the field from the preferences section and hardcode it in the device driver code,

Hmmm. Don't recall a size limit but let me investigate. (And thanks for working on this.)

I'm getting the "Thermostat has not been properly configured" error even though I put in my email, integrator token, and API key.

I also get the "org.apache.http.client.ClientProtocolException: null on line 132 (method configure)" when trying to configure. Thoughts on fixing these 2 issues?

Did you go through the "getting started" process on your Daikin? Daikin One Open API - Documentation

You will need to copy the API Key, your email, and the integrator token and paste them into the code where the blanks are (line 28 & line 126).

Yeah I copied all 3 of those on the 2 lines. Not sure why it's not working.

Are you able to call the token config endpoint outside of the app? Something like this:

curl -X POST \
  --header "x-api-key: API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"email":"YOUR EMAIL", "integratorToken":"YOUR INTEGRATOR TOKEN"' \
  https://integrator-api.daikinskyport.com/v1/token

Sorry not so savvy with programming. Where should I put this code in to test the login works.

Edit; I was able to use something outside the app and was able to get it to work. So my api key, email, and integrator token works. I just can't get it to work with the driver app.

Edit 2: I figured it out with some help with ChatGPT. For some reason, the URI was not being pulled. I fixed it by making the URI a preference and inputting the URI in the device and made some adjustments to getAuth() to help with debugging.

take a look at Faiken. GitHub - revk/ESP32-Faikin: ESP32 based module to control Daikin aircon units

You can run curl in a terminal/cmd prompt. Sounds like that isn't an issue anymore though.

Were you able to get it working? How did you update the uri?

That is a huge undertaking - really cool project though. If only there was a way to do it without the need for another piece of hardware...

I updated getAuth() as shown below and was able to retrieve the token. After that everything else worked.

    String getAuth() {
        try {
            Map requestParams = [
                uri: "https://integrator-api.daikinskyport.com/v1/token",
                headers: [
                    'Content-Type': 'application/json',
                    'x-api-key': settings.apiKey
                ],
                body: JsonOutput.toJson([
                    email: settings.email,
                    integratorToken: ""
                ])
            ]
            
    	    httpPost(requestParams) { resp ->
                if (resp.status == 200 && resp.data?.accessToken) {
                    authKey = resp.data?.accessToken
                    log.debug "Authentication successful, Token: $authToken"
                } else {
                    log.error "Authentication failed with status ${resp.status}"
                }
            }
        } catch (Exception e) {
            log.error "Error during authentication: $e.message"
        }     
        return authKey
    }