Author Topic: Ecobee 3 Plugin --> How long does a PIN last?  (Read 1185 times)

Offline gniknalu

  • Full Member
  • ***
  • Posts: 178
  • Karma: +3/-2
Ecobee 3 Plugin --> How long does a PIN last?
« on: February 12, 2018, 12:37:59 pm »
I updated my ecobee 3 plugin's PIN number the middle of last week. This morning Vera is saying, "ecobee : Not yet authorized. Press 'Get PIN' once; wait for PIN; enter at ecobee.com." Yet in the Ecobee web interface - it shows that Vera is still authorized.  How long does this authorization last? IF this is a Vera error, where do I look to find out why it is not retaining the authorization?

Thanks!

Offline Mike Yeager

  • Hero Member
  • *****
  • Posts: 582
  • Karma: +9/-12
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #1 on: February 13, 2018, 08:20:16 pm »
The PIN is simply to authorize the device to the Ecobee website. What happens is that the plugin needs a new access token from time to time and it's supposed to happen without any user interaction. If, for some reason, it misses the new token (or reboots before it's committed to storage), then you get the message you describe. There's more to it than this, but that's the jist of it. Remove the "app" from the Ecobee web page and use the new PIN to authorize it again. Used to happen to me fairly often, now it's rare. Reboots seem to be the usual cause, at least for me...

Offline gniknalu

  • Full Member
  • ***
  • Posts: 178
  • Karma: +3/-2
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #2 on: February 15, 2018, 10:59:49 pm »
The PIN is simply to authorize the device to the Ecobee website. What happens is that the plugin needs a new access token from time to time and it's supposed to happen without any user interaction. If, for some reason, it misses the new token (or reboots before it's committed to storage), then you get the message you describe. There's more to it than this, but that's the jist of it. Remove the "app" from the Ecobee web page and use the new PIN to authorize it again. Used to happen to me fairly often, now it's rare. Reboots seem to be the usual cause, at least for me...

I just came back from "fixing" it by deleting the app(s) and reinstalling them. Then reauthorized it and was enjoying the functionality for at least 3 - 5 days before this informative message.

Yes - there was a forced reboot but it was Saturday - many days after the authorization.

Will go thru the delete/re-add procedure once again. . . . Thanks for responding.

Offline Mike Yeager

  • Hero Member
  • *****
  • Posts: 582
  • Karma: +9/-12
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #3 on: February 17, 2018, 08:59:43 pm »
The Vera is likely rebooting without your knowledge. Mine still does it from time to time for reasons I haven't determined as of yet. It was doing it several times a day and that appeared to be caused by the ERGY plugin (that is installed by default). All it takes is one reboot at the wrong time. Hope you get this ironed out before you get too frustrated. I haven't had to reauthorize in weeks...

Offline rafale77

  • Hero Member
  • *****
  • Posts: 1340
  • Karma: +67/-23
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #4 on: February 17, 2018, 09:00:47 pm »
I have been going for months without this problem. The big factor is to not have the vera reload luup right at the time the token is changing. The API changes the token on a regular basis. For example if you load a config from backup on your vera, you are very likely to have renew your token.
I have been able to stabilize the vera enough to go weeks between a luup restart by moving a lot of my plugins and scenes/automation to Openluup. You can track the reboots by installing the system monitor plugin and set it to send a notification every time luup reloads.
openLuup (97 devices, 134 scenes, 20 apps) controlling HomeAss + VeraPlus (138 zwave nodes, 8 Zigbee nodes, 205 devices, 20 scenes , 2 app) Bridged to Homekit and Alexa. VeraPlus ExtRooted!

Offline gniknalu

  • Full Member
  • ***
  • Posts: 178
  • Karma: +3/-2
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #5 on: February 19, 2018, 02:08:10 pm »
I have been going for months without this problem. The big factor is to not have the vera reload luup right at the time the token is changing. The API changes the token on a regular basis. For example if you load a config from backup on your vera, you are very likely to have renew your token.
I have been able to stabilize the vera enough to go weeks between a luup restart by moving a lot of my plugins and scenes/automation to Openluup. You can track the reboots by installing the system monitor plugin and set it to send a notification every time luup reloads.

I think the issue is the stability of my Vera Secure. It seems when I have hard reboots, when it awakes everything is screwed up. Wondering if the PIN persists somewhere that is volatile and when I have to do a forced reboot, it is erased.

Well, I've reset it yet again. Thanks for everyone's feedback.

Offline gniknalu

  • Full Member
  • ***
  • Posts: 178
  • Karma: +3/-2
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #6 on: February 23, 2018, 09:11:27 am »
I reset it on the 17th. My Vera unit hasn't needed a force reboot during that time. This morning it asked me to get another PIN. So it lasted 7 days. ALTHOUGH on the Ecobe3 app side, it said the previous PIN was still authorized. So it undoubtedly is the Ecobee app.

Offline rafale77

  • Hero Member
  • *****
  • Posts: 1340
  • Karma: +67/-23
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #7 on: February 23, 2018, 10:25:47 am »
I reset it on the 17th. My Vera unit hasn't needed a force reboot during that time. This morning it asked me to get another PIN. So it lasted 7 days. ALTHOUGH on the Ecobe3 app side, it said the previous PIN was still authorized. So it undoubtedly is the Ecobee app.

The way this token works is:
1. The app sends a request to the API with a 4 letter code,
2. The API generates a token
3. We manually need login into the ecobee account and link the 4 letter code of the app to the API token.
4. The app then connects to the API using this token.
5. The API periodically changes the token. When this occurs it sends a sync up to the app.
6. The App receives the new token and updates it.

If your unit does a Luup reload right when step 5 occurs (or if your internet was disconnected), it misses that the token was renewed so the token is out of sync and you have to manually reconnect by going back to step 1. Of course the API will tell you the link is still valid. The API token is renewed, it is the vera which missed the change while rebooting itself.

The issue is the timing of your luup reload. I don't know anyway around it. It is just that the Ecobee API is pretty strict on these security token.
I have been using this app for many years now and stability has dramatically improved over time without changing the app but by reducing the frequency of Luup reloads... I did this by reducing the loading on the vera, removing apps, removing devices and scenes etc... As I am gradually obsoleting the vera as well turning it into just a zwave stick.
« Last Edit: February 23, 2018, 10:39:14 am by rafale77 »
openLuup (97 devices, 134 scenes, 20 apps) controlling HomeAss + VeraPlus (138 zwave nodes, 8 Zigbee nodes, 205 devices, 20 scenes , 2 app) Bridged to Homekit and Alexa. VeraPlus ExtRooted!

Offline gniknalu

  • Full Member
  • ***
  • Posts: 178
  • Karma: +3/-2
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #8 on: February 23, 2018, 10:55:37 am »
If your unit does a Luup reload right when step 5 occurs (or if your internet was disconnected), it misses that the token was renewed so the token is out of sync and you have to manually reconnect by going back to step 1. Of course the API will tell you the link is still valid. The API token is renewed, it is the vera which missed the change while rebooting itself.

The issue is the timing of your luup reload. I don't know anyway around it. It is just that the Ecobee API is pretty strict on these security token.
I have been using this app for many years now and stability has dramatically improved over time without changing the app but by reducing the frequency of Luup reloads... I did this by reducing the loading on the vera, removing apps, removing devices and scenes etc... As I am gradually obsoleting the vera as well turning it into just a zwave stick.

WOW - that explains it! We did experience internet issues with one of my routers - it lost internet connectivity for about 1 hour and it had to be rebooted. That must have been the time the new token was sent!

OK - I'll chill. But I wanted to THANK YOU for this explanation! It really cleared things up! If I ever get extra time in my life, I'd love to learn how to develop in this 'language' so I can help update apps. . . Thanks again rafale77

Offline rafale77

  • Hero Member
  • *****
  • Posts: 1340
  • Karma: +67/-23
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #9 on: February 23, 2018, 11:01:38 am »
No Problem, I only somewhat merely reverse engineered someone else's code to make it work on UI7 and learned how it works in the process. It was originally written for UI5.
The irony of it all is that the last remaining source of my Luup reloads is currently the Hue2 Plugin which is a MCV app. All the other 3rd party plugin I have (and I run a lot of them) do not cause unwanted Luup reloads.
openLuup (97 devices, 134 scenes, 20 apps) controlling HomeAss + VeraPlus (138 zwave nodes, 8 Zigbee nodes, 205 devices, 20 scenes , 2 app) Bridged to Homekit and Alexa. VeraPlus ExtRooted!

Offline gniknalu

  • Full Member
  • ***
  • Posts: 178
  • Karma: +3/-2
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #10 on: March 08, 2018, 10:52:54 am »
No Problem, I only somewhat merely reverse engineered someone else's code to make it work on UI7 and learned how it works in the process. It was originally written for UI5.

As I've stated, when it works, it's great!   :)

But I've basically given up on the PIN issue and will let it sit around without being in sync until something changes with how it is working.

Offline timtownsend

  • Sr. Newbie
  • *
  • Posts: 25
  • Karma: +0/-0
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #11 on: July 14, 2018, 06:04:46 pm »
As someone going through this same issue with Ecobee and Vera, this thread has been very helpful, thanks. I'm using Vera and PLEG to control window fans during the summer, turning them on when the outside temperature drops below the inside temperature. I use the Ecobee remote sensors in each room to compare with the outside temperature. I was very frustrated that the Ecobee sensors would just simply stop updating, remaining stuck at the same temperature until I deleted and re-added them to my Ecobee account with a new PIN. PINs only seem to last for a few days.

If I could add something, I have found that there is a variable called "status" in the Ecobee device that has a value of 1 when everything is fine, and 0 when the connection has been lost. To get a better handle on this issue, I set up a notification on this variable, and have observed that sometimes the status goes to 0 for a few secods or minutes, and then comes back on its own, but other times it remains disconnected/status 0 until a new PIN is used.

There are additional variables (auth_token, access_token, and refresh_token) that seem to hold, or are related to, the token that rafale77 mentioned. Would there be some way to have the device automatically sense when the status has been 0 for some period of time, and then update the token automatically?

Offline rafale77

  • Hero Member
  • *****
  • Posts: 1340
  • Karma: +67/-23
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #12 on: July 15, 2018, 01:01:33 am »
As someone going through this same issue with Ecobee and Vera, this thread has been very helpful, thanks. I'm using Vera and PLEG to control window fans during the summer, turning them on when the outside temperature drops below the inside temperature. I use the Ecobee remote sensors in each room to compare with the outside temperature. I was very frustrated that the Ecobee sensors would just simply stop updating, remaining stuck at the same temperature until I deleted and re-added them to my Ecobee account with a new PIN. PINs only seem to last for a few days.

If I could add something, I have found that there is a variable called "status" in the Ecobee device that has a value of 1 when everything is fine, and 0 when the connection has been lost. To get a better handle on this issue, I set up a notification on this variable, and have observed that sometimes the status goes to 0 for a few secods or minutes, and then comes back on its own, but other times it remains disconnected/status 0 until a new PIN is used.

There are additional variables (auth_token, access_token, and refresh_token) that seem to hold, or are related to, the token that rafale77 mentioned. Would there be some way to have the device automatically sense when the status has been 0 for some period of time, and then update the token automatically?

The token change is actually initiated by the ecobee server. It is up to the ecobee app to receive the token and then adjust its communication accordingly. Mine stays up for months at a time but it is because I moved it to openLuup. The issue is that the vera slows down, hangs and reboots much too frequently causing the ecobee plugin to often miss the token from the server. At that point the communication is broken and you have to reinitiate. The solution if you have to run it on the vera is to eliminate the random spontaneous luup reload which is something I am still fighting and am about to give up on.
openLuup (97 devices, 134 scenes, 20 apps) controlling HomeAss + VeraPlus (138 zwave nodes, 8 Zigbee nodes, 205 devices, 20 scenes , 2 app) Bridged to Homekit and Alexa. VeraPlus ExtRooted!

Offline Mike Yeager

  • Hero Member
  • *****
  • Posts: 582
  • Karma: +9/-12
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #13 on: July 16, 2018, 10:18:30 am »
I have completely defeated this issue. My Ecobee now interfaces my home automation through Home Assistant. Slowly moving most of my automation over to it. Will still be keeping the Vera in the loop mostly for access to Alexa (without any effort on my part)...

Offline rafale77

  • Hero Member
  • *****
  • Posts: 1340
  • Karma: +67/-23
Re: Ecobee 3 Plugin --> How long does a PIN last?
« Reply #14 on: July 16, 2018, 02:10:18 pm »
I have completely defeated this issue. My Ecobee now interfaces my home automation through Home Assistant. Slowly moving most of my automation over to it. Will still be keeping the Vera in the loop mostly for access to Alexa (without any effort on my part)...

Yes that's another way to do it. I have a number of devices set up that way and then reporting into openLuup but the vera plugin actually works very well directly on openLuup so I did not feel the need t move it over.
openLuup (97 devices, 134 scenes, 20 apps) controlling HomeAss + VeraPlus (138 zwave nodes, 8 Zigbee nodes, 205 devices, 20 scenes , 2 app) Bridged to Homekit and Alexa. VeraPlus ExtRooted!