haywirecoder / homebridge-flobymoen

Homebridge Module for Flo by Moen Smart Water System
MIT License
14 stars 2 forks source link

Location Load Error: Request failed with status code 401 #5

Closed johnynfulleffect closed 2 years ago

johnynfulleffect commented 2 years ago

I have not gotten this plugin to work yet with Homebridge and my Flo-by-Moen sensors. Seeing this in the logs in Homebridge:

Flo API Initization Failure: [Error: EACCES: permission denied, mkdir '.node-persist'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '.node-persist'
}
johnynfulleffect commented 2 years ago

Also seeing this error as well:

Location Load Error: Request failed with status code 401
haywirecoder commented 2 years ago

Hmm... The first error, is the result of failure of caching the access token. The plug-in assumes the default location has needed permissions. Are you getting message "Token will refresh in ..." message? Or is "Location Load Error..." is right after?

Let me look into the storage location issue, I may have to be specific on the locations.

Can tell what version of Homebridge you are using?

johnynfulleffect commented 2 years ago

I do not see those errors you mentioned, but I also see: "Login Error: storage.setItem is not a function" right before the "Request failed with status code 401".

I'm on Homebridge v1.3.5 in docker managed by k3s, if that makes a difference.

haywirecoder commented 2 years ago

Hi,

I couldn't reproduce the problem, but I am pretty sure this has to do with caching the access token to disk. I have uploaded a correction in flomain.js and index.js, which uses the Homebridge storagePath which should be the proper place to place these files. You can replace those files directly to see if it corrects the issue. I am also going to see if I can just put an options not cache to the local storage system, which avoid this issue completely.

Also concern, that the plug-in didn't just exit, so will correct this as well in the next version.

johnynfulleffect commented 2 years ago

Sure, I will give it a shot. You said you uploaded those two files? Where would that be? Found em, testing now!

johnynfulleffect commented 2 years ago

So far so good! I see:

[10/25/2021, 11:27:45 PM] [Flo-by-Moen] Token will refresh in 11 hour(s) and 59 mins(s).
[10/25/2021, 11:27:45 PM] [Flo-by-Moen] Initiaizing Flo devices...

And no errors! I see them in Homekit now.

Thanks!

haywirecoder commented 2 years ago

Great! I will release a new version shortly with this code, while I work on other options.

haywirecoder commented 2 years ago

Issue corrected in release 1.0.1