Can't get PIN for Ecobee binding

Hi there. I’m a complete beginner with openHAB. I’m looking to integrate my Ecobee3 into the system and to eventually communicate with my ISY 994i (universal-devices.com). I have the openHAB 1.7.1 runtime working on my RPi2 and have been messing around with the demo openhab.cfg and items files. I do have the ecobee binding .jar file in the correct folder with the other bindings. The problem is that I can’t seem to get the four character PIN from the Ecobee side to enter into the Ecobee web portal. I get ‘null’, rather than a value.

I updated the logback.xml file to dump the ecobee log entries into their own file. That file is now full of entries that look like this:

2015-10-17 22:08:36.563 WARN  o.o.b.e.internal.EcobeeBinding[:227]- Periodic poll skipped for 'DEFAULT_USER'.
2015-10-17 22:11:36.959 INFO  o.o.b.e.internal.EcobeeBinding[:961]- #########################################################################################
2015-10-17 22:11:36.960 INFO  o.o.b.e.internal.EcobeeBinding[:962]- # Ecobee-Integration: U S E R   I N T E R A C T I O N   R E Q U I R E D !!
2015-10-17 22:11:36.961 INFO  o.o.b.e.internal.EcobeeBinding[:963]- # 1. Login to www.ecobee.com using your 'DEFAULT_USER' account
2015-10-17 22:11:36.962 INFO  o.o.b.e.internal.EcobeeBinding[:964]- # 2. Enter the PIN 'null' in My Apps within the next null minutes.
2015-10-17 22:11:36.963 INFO  o.o.b.e.internal.EcobeeBinding[:966]- # NOTE: Any API attempts will fail in the meantime.
2015-10-17 22:11:36.964 INFO  o.o.b.e.internal.EcobeeBinding[:967]- #########################################################################################

I created a developer account with Ecobee and got both a “Consumer Key” and “Consumer Secret” alphanumeric code. I’ve tried both of them, but neither seems to work in the appkey property of in the openhab.cfg file. Here’s what I have in the file:

################################ Ecobee Binding #######################################
#
# Data refresh interval in ms (optional, defaults to 180000)
# ecobee:refresh=180000

# the temperature scale to use when sending or receiving temperatures
# optional, defaults to Fahrenheit (F)
ecobee:tempscale=F

# the private API key issued be Ecobee to use the API (replace with your own)
ecobee:appkey=hmp143zhq5css8xhxl8fc6lnwmtdrw7j
# the application scope used when authorizing the binding
# choices are smartWrite,smartRead, or ems, or multiple (comma-separated, no spaces)
ecobee:scope=smartRead

#########################################################

I do see this line show up in the main openhab log. It happens every 3 minutes, which is the ecobee binding refresh time…

2015-10-17 23:20:49.701 [WARN ] [g.openhab.io.net.http.HttpUtil] - Method failed: HTTP/1.1 401 Unauthorized

I updated the logging to “TRACE” level and saw this:

2015-10-17 23:33:15.820 TRACE o.o.b.e.internal.EcobeeBinding[:951]- Request: AuthorizeRequest[appKey=hmp143zhq5css8xhxl8fc6lnwmtdrw7j,scope=smartRead]
2015-10-17 23:33:16.327 TRACE o.o.b.e.internal.EcobeeBinding[:954]- Response: AuthorizeResponse[error=invalid_client,errorDescription=Authentication error, invalid authentication method, lack of credentials, etc.,errorURI=http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-5.2,ecobeePin=<null>,authToken=<null>,scope=<null>,expiresIn=<null>,interval=<null>]

Are there other bindings required to get this to work? Or am I doing something wrong? Thanks in advance!!
-Todd

Hi Todd,

It’s the first report of this sort I can remember seeing. Your ecobee:appkey is the same number of letters as mine (32).

I’ve only ever used ecobee:scope=smartWrite. The docs says smartRead should work for read-only access, though, if you want openHAB to only have read-only access.

Also, you don’t have to specify ecobee:tempscale=F because that’s the default, but it shouldn’t hurt or be at all relevant to this stage either.

I have to think that there is something incorrect about how you defined your app at the ecobee developer site. Perhaps more information about how you set it up, maybe even screenshots, could educate me on what you set up.

Another thing to try, but I doubt it will help at this early stage, is to stop the openHAB server, delete the Java Preferences file where any bad tokens could be stored (on Linux, this should work: rm -rf ~/.java/.userPrefs), and restart the openHAB server. But I don’t think you have any tokens yet…

Last, and very much least likely, is a problem at ecobee.com that is the root cause of the issue.

Let me know what you are able to see and I will try to help more.

John

Thanks John. I tried the command on the RPi of rm -rf ~/.java… but that didn’t seem to help. I also tried commenting out the tempscale=F and changing back to smartWrite. None of that seemed to help.

I’m wondering if it has something to do with the “Default User” that’s showing up, or maybe the fact that I didn’t put anything into the “Callback URL” field of the Ecobee developer page. Do I need something in that field?
See screenshot below…

Uploading…

Or is there some other .jar file that I need to allow communications?

FWIW, I’m running the openHAB runtime on a RPi2 (fresh install with only openHAB and samba added onto the virgin image from the RPi website, which is connected to my router using a fixed IP addy. The server is running on the RPi and all seems well. I have Raspbian Jessie OS on the RPi and the openHAB runtime is located in the /opt/openhab folder.

I’m thinking the following message is related to the root cause:

...[g.openhab.io.net.http.HttpUtil] - Method failed: HTTP/1.1 401 Unauthorized

Any thoughts on that?

Thanks in advance!
-Todd

I can’t explain it, but somehow I was able to make it work. I would either blame it on the ecobee web portal or my own user error… probably the latter. :blush:

I followed the link you showed to the ecobee developer site and logged in with the info I set up yesterday. I then saw some fields that I hadn’t seen before, which included a “company name” that had a required asterisk next to it. Filled that out and logged into my ecobee web portal for my thermostat. A new DEVELOPER option appeared in the settings menu, which wasn’t there before. I set that up with yet another new app name and description and selected to use the PIN authentication method. Did that and it didn’t work (after seeing the null log entry a couple of times). Restarted the openHAB server after running the java clean tokens command and suddenly the PIN appeared in the message.

All is right in the world now! :smile:

Thanks for your help and now I’m off to start some programming with my new interface.

Cheers,
Todd

I’m glad you got it fixed, Todd. Wish I understood what the issue was. I was all the way to creating the attached screenshot in hopes of identifying what is required, in the off chance you were choosing the incorrect Authorization Method.

At first, I actually had done the app request form via the ecobee.com website, rather than through the web portal as you showed above. The ecobee website didn’t actually have the option to choose the authorization method as you point out in the screenshot above. The website had a configuration page like the one I showed in my second post, with the Callback URL. I imagine that this was defaulting to the other type of authentication (other than the 4 digit PIN).

Once I added the “company name” in the developer part of the website, the “DEVELOPER” option appeared in the web portal, which is what ultimately worked.

Thanks for your help! Now I need to get configuring my system. :smile:

1 Like

I’m also not getting the PIN number back … has this process changed by any chance ?

19:43:06.411 [WARN ] [.ecobee.internal.EcobeeBinding:287 ] - Exception reading from Ecobee:
org.openhab.binding.ecobee.internal.EcobeeException: Could not get authorization.
at org.openhab.binding.ecobee.messages.AbstractRequest.newException(AbstractRequest.java:61) ~[na:na]
at org.openhab.binding.ecobee.messages.AuthorizeRequest.execute(AuthorizeRequest.java:65) ~[na:na]
at org.openhab.binding.ecobee.internal.EcobeeBinding$OAuthCredentials.authorize(EcobeeBinding.java:1112) ~[na:na]
at org.openhab.binding.ecobee.internal.EcobeeBinding$OAuthCredentials.refreshTokens(EcobeeBinding.java:1143) ~[na:na]
at org.openhab.binding.ecobee.internal.EcobeeBinding.execute(EcobeeBinding.java:276) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) [org.openhab.core_1.8.2.jar:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) [org.openhab.core_1.8.2.jar:na]
Caused by: java.lang.NullPointerException: null
at java.io.StringReader.(StringReader.java:50) ~[na:1.8.0_65]
at org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.java:636) ~[na:na]
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1854) ~[na:na]
at org.openhab.binding.ecobee.messages.AuthorizeRequest.execute(AuthorizeRequest.java:61) ~[na:na]
… 5 common frames omitted

Is this the first use of the Ecobee app you created at ecobee.com? If so, double check your .cfg file against it and the wiki instructions. Share your configuration here if still no success (with private details masked).

Yes first App … I verified “PIN Authorization” method in Ecobee developer portal
Verified the appkey is correct 32 char code from ecobee developer portal , however I removed for posting here … it
Here is section from config file:

################################ Ecobee Binding #######################################

the private API key issued be Ecobee to use the API (required, replace with your own)

ecobee:appkey=<removed for posting – 32 char code that was obtained from ecobee portal>

the application scope used when authorizing the binding

choices are smartWrite,smartRead, or ems, or multiple (required, comma-separated, no spaces)

ecobee:scope=smartWrite

Rate at which to check if poll is to run, in ms (optional, defaults to 5000)

ecobee:granularity=5000

Data refresh interval in ms (optional, defaults to 180000)

ecobee:refresh=180000

Time in ms to wait after successful update, command or action before refresh (optional, defaults to 6000)

ecobee:quickpoll=6000

Time in ms to allow an API request to complete (optional, defaults to 20000)

ecobee:timeout=20000

the temperature scale to use when sending or receiving temperatures

optional, defaults to Fahrenheit (F)

ecobee:tempscale=C

Could you try these examples from the command line of your openHAB server? Replace API_KEY and AUTHORIZATION_CODE with your values. I wonder if there is a connectivity or service issue, but your empirical testing with cURL could help.

curl -X GET ‘https://api.ecobee.com/1/authorize?response_type=ecobeePin&client_id=API_KEY&scope=smartWrite

pasting in my key for API_KEY directly from Mac via terminal results in:

{
“status”: {
“code”: 1,
“message”: “Authentication failed. Token is required.”
}

same executing from RP3 via ssh from Mac terminal =

curl: (6) Could not resolve host: api.ecobee.com

I’m a little unclear why the RP3 is having issues resolving the url as DNS in resolv.conf appears correct

Any change this message on Ecobee developer support page is at play ?

EMPLOYEE
MarkK (API Architect) 2 months ago
Upcoming May 2016 updates to /token error responses.
Hello ecobee Developers,

We strive to continuously improve ecobee’s API by constantly reviewing
our actions and responding to your valuable feedback. In this regard, we
have two important updates planned for the ecobee API in the coming
month and wanted to notify the developer community in advance of
releasing the updates.

What updates are we making?

Fixing inconsistency between ecobee API OAuth token grant
& refresh error responses and those defined by the OAuth 2.0
specifications
Removing support for the RC4 cipher suite for SSL communication

Details are provided at the end of this email

How will this impact your applications?

The OAuth token grant & refresh error response update
has no impact to application behaviour where there may be scenarios that
should return errors and are not, and vice versa. These responses only
affect token grant and refresh calls made to
the api.ecobee.com/token endpoint.
You will need to update your application if it is using RC4 cipher suite for SSL communication

When will these updates take effect?

All the aforementioned updates will take place in the week of May 9th. We kindly request that you make any necessary adjustment prior to May 9th.

If you have questions or concerns, our API team is always available on our forum http://developer.ecobee.com/api and can be reached directly at developer@ecobee.com.

Update details

ecobee API Oauth token grant & refresh error responses:

It was pointed out by our developer community that there were
some inconsistencies between the ecobee API OAuth token grant &
refresh error responses, and those defined by the OAuth 2.0
specification (https://tools.ietf.org/html/rfc6749#section-5.2). These responses only affect the token grant and refresh calls made to the api.ecobee.com/token endpoint.

The table below summarizes the error message changes:

Request contains an empty “grant_type” parameter (an empty string or string with only whitespaces)

Old Error Response: unsupported_grant_type

New Error Response: invalid_request

A non-empty “grant_type” type value that is unsupported (e.g. “password”)

Old Error Response: invalid_request

New Error Response: unsupported_grant_type

“code” or “refresh_token” with invalid values

Old Error Response: invalid_client

New Error Response: invalid_grant

Application has been deauthorized by the ecobee user

Old Error Response: invalid_client

New Error Response: invalid_grant

ecobee user no longer exists (ecobee account has been deleted)

Old Error Response: invalid_client

New Error Response: invalid_grant

RC4 Cipher deprecation

As per the IETF guidelines (https://tools.ietf.org/html/rfc7465),
RC4 is no longer considered a secure cipher suite. Hence in the
interest of all our ecobee users we are depreciating the support for it
in the API.

We appreciate your understanding in adjusting to these changes. As always we welcome your feedback and questions

Ecobee still hasn’t fixed the cURL examples!

Here is an explanation of what is wrong with the official cURL examples and how to execute them successfully.

Thanks … you were a big help! After a few more perusals thru logs I power cycled the gig-e switch the RP3 was attached to and restarted OpenHAB, and voila! All appears working now …

Scott

1 Like

I’m also trying to add an ecobee to openhab. The ecobee website asks for “Please enter authorization code that was provided by the application you installed” to give me the key.

What 4 digit code should I enter?

The answer is a four-character code that was put in the openhab log at the INFO logging level. It was only valid for about 9 minutes or so you will probably have to restart openHAB to get a new PIN and then enter it at your account at ecobee.com. In an extreme case, delete your Java Preferences directory at ~/.java/.userPrefs and restart openHAB.

Thank you for the quick reply. Unfortunately I still do not know how to get the PIN:

Curiously, unlike other bindings, Ecobee does not show up in the installed bindings list in the Paper UI. I un-installed and re-installed. The log shows

15:03:12.807 [INFO ] [smarthome.event.ExtensionEvent ] - Extension ‘binding-ecobee’ has been installed.

but I cannot see PIN (log:display | grep ecobee only brings up the above message.

While ~/.java/.userPrefs should I delete? There is no such file in ~openhab.

Thanks,
Bernhard

If you look through your older logs, do you see a block of INFO logs showing the now-expired PIN? If not, then the binding has never reached the point where it tried to get tokens, and you should then look for the PaperUI-based configuration for the binding, where you can set API Key, Scope, Granularity, etc.

Oh, and this might be important! If you have no items defined bound to { ecobee="..." }, then the binding has no reason to talk to the API, and hence it won’t generate a PIN until you have bound some items in a .items file! This could explain why there are no Java Preferences stored at ~/.java/.userPrefs.

On the second point, I’ve now added the following to my items file:

// ecobee weird number: 316558281665
String ecobeeName "name [%s]" { ecobee="=[316558281665#name]" }
String ecobeeTemp "current temperature [%.1f C]" { ecobee="<[316558281665#runtime.actualTemperature]" }

and this to the sitemap file

    Frame label="Ecobee" {
    	Text item=ecobeeName
	Text item=ecobeeTemp
    }	

No Ecobee in the log file, and the items display with a text-like symbol that I’ve observed when openhab is not happy with an item definition.

In general, I’ve noticed that openhab2 seems to prefer item definitions with { channel=…} rather than other names. E.g. I’ve never gotten items declared with { zwave=…} working, though zwave devices specified with the channel notation work (sometimes).

Would you know if this is the case in general? A change from openhab 1.9 to openhab2 perhaps? That would explain that examples I copy verbatim from the various docs I’ve found generally do not work.

openHAB 1.x bindings use their ID to bind to items (like zwave=, ecobee=, etc.) while openHAB 2.x and Eclipse SmartHome bindings have channels they update, and those channels are linked to items. So if you are using an openHAB 1.x binding, follow the instructions in the appropriate wiki page (same as when running on openHAB 1.x runtime).

I uninstalled and then reinstalled the Ecobee binding in openHab 2. It still does not show up under the bindings tab - neither in Habmin nor the Paper UI.

However, Services/ecobee.cfg was created, with default values (all commented out).

Uncommenting the appkey provided in the default (the one I’m supposed to replace with my own) and the scope parameter in ecobee.cfg (scope=smartWrite) produces the following log entries:

22:00:17.757 [WARN ] [org.openhab.io.net.http.HttpUtil    ] - Method failed: HTTP/1.1 401 Unauthorized
22:00:17.959 [INFO ] [inding.ecobee.internal.EcobeeBinding] - #########################################################################################
22:00:17.960 [INFO ] [inding.ecobee.internal.EcobeeBinding] - # Ecobee-Integration: U S E R   I N T E R A C T I O N   R E Q U I R E D !!
22:00:17.961 [INFO ] [inding.ecobee.internal.EcobeeBinding] - # 1. Login to www.ecobee.com using your 'DEFAULT_USER' account
22:00:17.961 [INFO ] [inding.ecobee.internal.EcobeeBinding] - # 2. Enter the PIN 'null' in My Apps within the next null minutes.
22:00:17.962 [INFO ] [inding.ecobee.internal.EcobeeBinding] - # NOTE: Any API attempts will fail in the meantime.
22:00:17.962 [INFO ] [inding.ecobee.internal.EcobeeBinding] - #########################################################################################
22:00:17.963 [WARN ] [inding.ecobee.internal.EcobeeBinding] - Periodic poll skipped for 'DEFAULT_USER'.

Hmm, …

Enter the PIN 'null' in My Apps within the next null minutes.

Suggestions most appreciated!

Bernhard