iprak / sensi

HomeAssistant integration for Sensi thermostat
MIT License
43 stars 9 forks source link

Invalid credentials with refresh_token #41

Closed genregasm closed 6 months ago

genregasm commented 6 months ago

Followed instructions for 3/14/24 update. Obtained refresh_token, without quotes, from my login to manager.sensicomfort.com and entered it into HA integration request. "Invalid credentials." Result is immediate, integration does not load/"think" during this process. image

image

akseidel commented 6 months ago

Perhaps there was a miscopy. Try this. Select the “Application” tab instead of the “Network” tab in the Developer Tools. Then under “Storage” “Session storage” select the “refreshToken” Key in the presented Key, Value table. The “refreshToken” value will be shown below the Key, Value table without enclosing quotes for an easier select copy action.

iprak commented 6 months ago

What is your HA and Sensi version? I attempted adding Sensi with bad token and got this. Your prompt looks very different.

image

tschetschpi2 commented 6 months ago

Perhaps there was a miscopy. Try this. Select the “Application” tab instead of the “Network” tab in the Developer Tools. Then under “Storage” “Session storage” select the “refreshToken” Key in the presented Key, Value table. The “refreshToken” value will be shown below the Key, Value table without enclosing quotes for an easier select copy action.

This solved my issues after updating the files. Thank you to all for the work on getting this functional again!

akseidel commented 6 months ago

I could be wrong. I believed genregasm was trying to fix a broken Sensi integration as was I. The posted image of the prompt is similar to what I saw when responding to HA’s “Sensi needs reconfiguration”, except my refreshToken paste passed the test. My HA is 2023.11.2 with frontend 20231030.2. Sensi is the latest release v1.3.1.

TheJimmerJammer commented 6 months ago

this worked for me, however, the integration seems to fail after about 3-4 hours and it asks me to enter in another refresh token?

iprak commented 6 months ago

this worked for me, however, the integration seems to fail after about 3-4 hours and it asks me to enter in another refresh token?

I noticed that too. I should have a fix for that later today.

iprak commented 6 months ago

I could be wrong. I believed genregasm was trying to fix a broken Sensi integration as was I. The posted image of the prompt is similar to what I saw when responding to HA’s “Sensi needs reconfiguration”, except my refreshToken paste passed the test. My HA is 2023.11.2 with frontend 20231030.2. Sensi is the latest release v1.3.1.

Maybe uninstall/reinstall the integration. The authentication prompt should include a link to manager and more instructions.

akseidel commented 6 months ago

I also had to reconfigure again. After seeing these posts I restarted HA to see what would happen. Reconfigure was again required. The previous fix did not uninstall the Sensi integration. There is a file named “sensi” at config/.storage that looks like a json file containing “access_token” and “refresh_token” value pairs. Out of ignorance for me, like rubbing chicken bones together, I replaced both those values with the values (not also the key names) for “authToken” and “refreshToken” copied from the manager.sensicomfort.com website. The Sensi authentication became restored upon restarting HA. The authentication survived subsequent HA restarts so far and also a server reboot. All of that might be meaningless for all I know about the HA authentication process.

mondomondoman commented 6 months ago

When I go to https://manager.sensicomfort.com/ it redirects me to https://manager.sensicomfort.com/choose-plan. is anyone else having this issue or do I need to pay for a plan to get access to this.

tschetschpi2 commented 6 months ago

When I go to https://manager.sensicomfort.com/ it redirects me to https://manager.sensicomfort.com/choose-plan. is anyone else having this issue or do I need to pay for a plan to get access to this.

You need to have the developer tab of your browser open as you log in. You don't need to buy a plan. Check prior updates/documentation for the information you need to capture from there.

Menz01 commented 6 months ago

this worked for me, however, the integration seems to fail after about 3-4 hours and it asks me to enter in another refresh token?

Me as well

Brychance67 commented 6 months ago

this worked for me, however, the integration seems to fail after about 3-4 hours and it asks me to enter in another refresh token?

Same here. I enter in the same token, and it takes it, but the whole integration needs to be restarted before any controls work. Will probably try to get them into Homekit and try that route. Shame, it was really nice when it worked.

iprak commented 6 months ago

The token can expire. 1.3.2 has better support for renewing the token when data load indicates expiration.

neilbrookins commented 6 months ago

When the token expires, the frontend appears to display stale data. It doesn’t flag the entities as unavailable. This means I can adjust the desired temperature to a new temperature and it looks like it’s working. I see the new temperature set. But on the back end there is no communication. So the end user thinks they’ve set a new temperature when in reality the token expired means nothing is changing.

I think the solution (for expired) would be to set all entities as unavailable so the end user sees on the frontend that communication is down.

I understand that refreshing the token is the ultimate goal. But I’m trying to say that in the event of failure to authenticate the entities should not display stale (last known) values. Displaying unavailable is better.

iprak commented 6 months ago

The integration flags entities as unavailable based on online status i.e. thermostat being accessible from Sensi servers. It would be trivial to extend that to authentication failure.

iprak commented 6 months ago

The token refresh should be working (v1.3.2).

Brychance67 commented 6 months ago

The token refresh should be working (v1.3.2).

It looks like it is....so far it has not stopped working after a day or so. What I did was complete remove and delete the older version and just reinstall the integration and it's all good now. Thanks so much for your efforts.