hoobs-org / HOOBS

Build your Smart Home with HOOBS. Connect over 2,000 Accessories to your favorite Ecosystem.
https://hoobs.org
GNU General Public License v3.0
550 stars 51 forks source link

Plugin config.json shown in Advanced editor does not match contents seen by plugin #1853

Closed jlg89 closed 1 year ago

jlg89 commented 1 year ago

Description The homebridge-august plugin uses a validation process to register the plugin with the August mothership. When I follow this process and add the "validateCode" line to the config using the "Advanced" editor, and then restart the bridge, the plugin adds an "isValidated": true line to config.json. When I view the config.json in HOOBS Advanced editor, everything looks good, but if I look at the file in /var/lib/hoobs/[bridge name]/config.json, the "validateCode" line is not in there. IOW that line appears in the HOOBS web interface, but not in the file in the filesystem. According to Donovan Becker, this is a HOOBS issue, and of course his solution is to use stock homebridge and config-ui-x. It's not my intention to get into that debate, nor do I want to have to reconfigure everything from scratch.

Version 4.2.8

Did you upgrade

What device are you using? Please let us know the device you are running HOOBS on.

List your plugins homebridge-august homebridge-camera-ffmpeg homebridge-tcc homebridge-tplink-smarthome

Post your config This can be found in the interface, Configuration -> Advanced or you can get it via SSH cat ~/.hoobs/etc/config.json

{
    "accessories": [],
    "platforms": [
        {
            "platform": "August",
            "name": "August",
            "credentials": {
                "augustId": "xxx",
                "password": "xxx",
                "notice": "Keep your tokens a secret!",
                "validateCode": "123456",
                "logging": "debug",
                "isValidated": true
            },
            "options": {
                "devices": [
                    {
                        "lockId": "xxx",
                        "hide_device": false,
                        "lock": {
                            "hide_contactsensor": true
                        }
                    }
                ]
            }
        }
    ]
}

Post your log You can get the log from the interface. This is in the Log section.

2/6/2023, 8:25:31 PMDoor Access Bridge starting 2/6/2023, 8:25:34 PMDoor Access BridgeERRORThe plugin "homebridge-august" requires a Homebridge version of ^1.6.0 || ^2.0.0-beta.0 which does not satisfy the current Homebridge version of 1.5.0. You may need to update this plugin (or Homebridge) to a newer version. You may face unexpected issues or stability problems running this plugin. 2/6/2023, 8:25:36 PMDoor Access BridgeLoaded plugin 'homebridge-august' 2/6/2023, 8:25:36 PMDoor Access BridgeLoading 1 platforms... 2/6/2023, 8:25:36 PMDoor Access BridgeAugustERRORDiscover Devices: ReferenceError: Config errors found: Missing config.installId or AUGUST_INSTALL_ID env var 2/6/2023, 8:25:36 PMDoor Access BridgeBridge is running on port 51846.

Additional context Add any other context about the problem here.

jlg89 commented 1 year ago

HOOBS is doing something that keeps the plugin from making the necessary edits to its config.json file. Specifically, it should be adding an "installID" line and removing the "validateCode" line, but that isn't happening.

jlg89 commented 1 year ago

Not a straightforward fix, but this works for getting this plugin to run under HOOBS 4.2.8. Maybe HOOBS 4.3 will fix this, but I'm not holding my breath.

The trick is getting the august-api node module to give you the installId value, which is not getting written to the config.json for whatever reason.

Edit /var/lib/hoobs/[child_bridge_name]/node_modules/august-api/src/util/session.js

At the end of the file, find:

headers['x-august-access-token'] = this.token
console.log('Using installId: ', installId) <—insert this line & save
return headers

Restart the bridge containing the homebridge-august plugin. You’ll have to go back through the authentication steps, but the installId should start showing up in the HOOBS debug log (not the plugin’s debug log, you have to enable debug on the HOOBS log page).

Once you have the installId, edit the homebridge-august plugin config (using the Advanced editor). Replace the “validateCode”: “123456" line with “installId”: “your-installId-string” and save it. The plugin should now work properly, and survive restarts.

You can leave the session.js file as-is, but I’d revert it to the original, as it’s pretty chatty with that console.log line in there.