-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concurrent writings to hombebridges config.json when using ioBroker #1588
Comments
What does "change the way it is stored" mean, the plugin simply stores the token using native Homebridge capabilities, which just writes it to to the Homebridge config file, they can read it from that file as well as anyone, just like all other settings. If they are not picking up or are overwritting such settings then, IMO, they are not properly supporting Homebridge plugins. I'm not sure why the plugin code should be changed to handle this. Isn't there a native ioBroker adapter for Ring anyway? |
Hm, the config.json file is written in https://github.com/dgreif/ring/blob/main/packages/homebridge-ring/config.ts by fs.writeFileSync(), IMHO thats not a native Homebridge capability. Although I already tried to find other homebridge plugins doing the same to proof that this is at least "best practice" but found none so far. Of course in general its quite usual that a software writes to its own config file. The only native ring Adapter for ioBroker does only support ring cameras but not ring alarm - which I need to connect to. |
Fair enough, I just meant that it updates the existing property in the default homebridge configuration file, and I'm not sure where else would be appropriate, since the token is, as of today, part of the plugin configuration. I had a similar issue in ring-mqtt, in early versions I kept the token in the config file, but I also have various per-device settings like snapshot intervals, sensor bypass modes, etc, that I needed to keep for each device, and it didn't seem to make sense to keep that in the config file, plus I didn't want the token displayed in the config UI, so I moved all of that to a ring-state.json file. I suppose a similar concept could work here. However, I would have to defer this to @dgreif as it's been this way from the start, appears to work for 1000's of users for years now, and I'm not sure if it's worth the effort and risk just because it doesn't work with some 3rd party tool that appears to use Homebridge in an unexpected way. |
Just for a bit of research, the only specific recommendation seems to be:
Based on this, it could be argued that the token should be stored in a separate file in the storagePath(), however, this is a bit complicated by some other requirements such as:
Today, I'm pretty sure we don't start if there's no token, as that's the only required configuration. For most users, the initial token is generated via web UI, which does use standard Homebridge UI API to set the refreshToken property. So we'd need to use the token initially, and then probably put a placeholder there so the code would use a new token, but we also allow users to generate a new token so we'd need to use he token from the config if the placeholder wasn't there. |
I don't think that will solve my problem, it would just be a hassle for you with no benefit. What if the user wants to set a new token themselves? |
Yes, that would certainly be the best option. |
Is there an existing issue for this?
Describe The Bug
I use the iobroker.ham homebrige adapter for ioBroker to run homebridge-ring. On every start of that adapter it writes all its internally known config to homebridges config.json which then leads to inconsistencies regarding my refreshToken as this is updated in config.json but not written back to ioBrokers internal configuration by the iobroker.ham adapter.
The developers of that ioBroker adapter asked me to reach out to you to ask if there is a way to change the way upated refreshTokens are stored. Although I think this problem is caused by ioBroker.homebridge as its not a problem running homebridge-ring in a stanalone homebridge environment.
To Reproduce
No response
Expected behavior
refreshToken not beeing overwritten
Relevant log output
Screenshots
No response
Homebridge Ring Config
Additional context
No response
OS
Linux
Node.js Version
20.18.2
NPM Version
10.8.1
Homebridge/HOOBs Version
unknown as integrated in adaper
Homebridge Ring Plugin Version
13.2.1
Operating System
Debian
The text was updated successfully, but these errors were encountered: