haywirecoder / homebridge-flobymoen

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

Unable to Control Aux Switch - Reference Error and Plugin Crash #16

Closed eematt closed 1 month ago

eematt commented 1 month ago

Describe The Bug: When attempting to control (open or close) the Flo by Moen using the aux switch either via HomeBridge web UI or Apple Home iOS app, the control fails and causes HomeBridge to restart.

To Reproduce: 1- Configuring Flo by Moen plugin with control and aux switch enabled. 2- Verifying polling and control using standard smart control tile using the HomeBridge web UI or Apple Home app to control. 3- Attempt to control valve with aux switch.

Expected behavior: Valve opens and closed when using aux switch.

Logs: [14/07/2024, 15:41:11] Homebridge v1.8.3 (HAP v0.12.2) (Homebridge B773) is running on port 51633. [14/07/2024, 15:41:11] [Flo-by-Moen] Flo Info: Using local cache Flo token. [14/07/2024, 15:41:11] [Flo-by-Moen] Flo Info: Token will refresh in 10 hour(s) and 51 min(s). [14/07/2024, 15:41:11] [Flo-by-Moen] Initializing Flo devices... [14/07/2024, 15:41:12] [Flo-by-Moen] Flo device updates complete, background polling process started. Device will be polled each 1 min(s) 30 second(s). [14/07/2024, 15:42:01] ReferenceError: FLO_VALVE_CLOSE is not defined at FloOptionSwitch.setAuxSwitch (/var/lib/homebridge/node_modules/homebridge-flobymoen/accessories/optionSwitch.js:115:43) at On. (/var/lib/homebridge/node_modules/homebridge-flobymoen/accessories/optionSwitch.js:60:52) at On.emit (node:events:518:28) at /var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2601:16 at new Promise () at On. (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2599:14) at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:195:27) at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:176:57) at /var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:169:75 at new Promise () [14/07/2024, 15:42:01] Got SIGTERM, shutting down Homebridge... [14/07/2024, 15:42:01] [Homebridge UI] [HapClient] [127.0.0.1:51633 (0E:66:AA:CB:B7:73)] Failed to set value for Irrigation Valve Valve Switch. [14/07/2024, 15:42:06] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null [14/07/2024, 15:42:11] [HB Supervisor] Restarting Homebridge... [14/07/2024, 15:42:11] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules --strict-plugin-resolution [14/07/2024, 15:42:11] [HB Supervisor] Started Homebridge v1.8.3 with PID: 7624 [14/07/2024, 15:42:13] Loaded config.json with 0 accessories and 2 platforms. [14/07/2024, 15:42:13] Loaded 2 cached accessories from cachedAccessories. [14/07/2024, 15:42:13] --- [14/07/2024, 15:42:13] Loaded plugin: homebridge-flobymoen@1.0.11 [14/07/2024, 15:42:13] Registering platform 'homebridge-flobymoen.Flo-by-Moen' [14/07/2024, 15:42:13] --- [14/07/2024, 15:42:13] Loading 2 platforms... [14/07/2024, 15:42:13] [Flo-by-Moen] Initializing Flo-by-Moen platform... [14/07/2024, 15:42:13] [Flo-by-Moen] Starting communication with Flo portal

Show the Homebridge logs here, remove any sensitive information.

Plugin Config:


{
    "name": "Flo-by-Moen",
    "auth": {
        "username": <hidden>,
        "password": <hidden>
    },
   "disableCache": false,
    "showTemperatureAndHumidity": true,
    "enableValveControl": true,
    "showHealthTestSwitch": false,
    "showAuxSwitch": true,
    "treatWarningAsCritical": false,
    "surpressWaterNotification": false,
    "deviceRefresh": 90,
    "offlineTimeLimit": 4,
    "sleepRevertMinutes": 120,
    "retryErrorDisplay": 3,
    "showFloTemperature": true,
    "showGPMPSIasLight": false,
    "platform": "Flo-by-Moen"
}

Screenshots:

Environment:

haywirecoder commented 1 month ago

Post a new version of /accessories/optionSwitch.js which should fix the issue. Will need to test when I have a few moment and will release once I have tested in my environment.

eematt commented 1 month ago

Thank you! After reviewing the changelog and reading the history on enhancement number 12, I learned that the ability to control the valve via automations and scenes was already possible using the Eve app. Since then I have accomplished what I was intending to do using the Eve app. I do like the idea of being able to work with automations and scenes within the Apple Home app but don't see it as a requirement since it's possible within the Eve app. I recommend in the description for the showAuxSwitch option in the configuration option guide a comment be added about the possibility of using other HomeKit applications outside of the Apple Home app to get better control of the Flo valve with scenes and automations. This could help others who might overlook the changelog and not think about the possibility that functionality could be different between HomeKit applications. This is something I knew of but forgot about when troubleshooting this issue. Thank you very much for your work! It is much appreciated!

haywirecoder commented 1 month ago

Good suggestion and will add it to the description when I release this fix. I personally just use the Eve App myself to automate the valve and it work flawlessly -- Hence why I miss this simple issue, since this was really out of request from community. Happy automating.

haywirecoder commented 1 month ago

Corrected in version 1.0.12