haywirecoder / homebridge-flobymoen

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

Flo Device Error: Cannot read properties of undefined (reading 'psi') #15

Closed jryburn closed 3 months ago

jryburn commented 3 months ago

Describe The Bug: Getting an error when the plugin attempts to read the PSI from the Flo API. It appears to stop there as I do not see any discovered devices in the Accessories screen.

To Reproduce: Happens in my setup every time the plugin restarts.

Expected behavior: I would expect that the plugin would read my Flo device and provide metrics and a switch to be able to turn on/off the water.

Logs:

[5/29/2024, 10:46:16 AM] Homebridge v1.8.2 (HAP v0.12.1) (Homebridge 97BF) is running on port 51189.
[5/29/2024, 10:46:16 AM] [Flo-by-Moen] Launched child bridge with PID 135765
[5/29/2024, 10:46:16 AM] Registering platform 'homebridge-flobymoen.Flo-by-Moen'
[5/29/2024, 10:46:16 AM] [Flo-by-Moen] Loaded homebridge-flobymoen v1.0.9 child bridge successfully
[5/29/2024, 10:46:16 AM] [Flo-by-Moen] Starting communication with Flo portal
[5/29/2024, 10:46:16 AM] [Flo-by-Moen] Flo Info: Using local cache Flo token.
[5/29/2024, 10:46:16 AM] [Flo-by-Moen] Flo Info: Token will refresh in 11 hour(s) and 23 min(s).
[5/29/2024, 10:46:16 AM] [Flo-by-Moen] Initializing Flo devices...
[5/29/2024, 10:46:16 AM] Loaded 9 cached accessories from cachedAccessories.0E7CD845C754.
[5/29/2024, 10:46:17 AM] [Flo-by-Moen] Flo Device Error: Cannot read properties of undefined (reading 'psi')

Plugin Config:

{
    "bridge": {
        "name": "Homebridge 97BF",
        "username": "{{redacted}}",
        "port": 51189,
        "pin": "{{redacted}}",
        "advertiser": "bonjour-hap"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        },
        {
            "name": "Tuya",
            "options": {
                "projectType": "2",
                "accessId": "{{redacted}}",
                "accessKey": "{{redacted}}",
                "countryCode": 1,
                "username": "{{redacted}}",
                "password": "{{redacted}}",
                "appSchema": "smartlife",
                "debug": false
            },
            "platform": "TuyaPlatform",
            "_bridge": {
                "username": "{{redacted}}",
                "port": 53313
            }
        },
        {
            "name": "Elgato Key Lights",
            "powerOnBehavior": 1,
            "switchOnDurationMs": 100,
            "platform": "ElgatoKeyLights",
            "_bridge": {
                "username": "{{redacted}}",
                "port": 59992
            }
        },
        {
            "name": "iRobot",
            "logLevel": 3,
            "autoConnect": true,
            "alwaysShowModes": false,
            "accessories": [
                {
                    "name": "Little Buddy",
                    "blid": "{{redacted}}",
                    "password": "{{redacted}}",
                    "sw": "lewis+22.52.10+2023-10-03-e032ab4903c+Firmware-Build+4820",
                    "sku": "i655020",
                    "ipResolution": "lookup",
                    "hostname": "{{redacted}}"
                }
            ],
            "platform": "iRobotPlatform",
            "_bridge": {
                "username": "{{redacted}}",
                "port": 36793
            }
        },
        {
            "name": "Nest",
            "googleAuth": {
                "issueToken": "{{redacted}}",
                "cookies": "{{redacted}}"
            },
            "platform": "Nest",
            "_bridge": {
                "username": "{{redacted}}",
                "port": 37243
            }
        },
        {
            "name": "Flo-by-Moen",
            "auth": {
                "username": "{{redacted}}",
                "password": "{{redacted}}"
            },
            "disableCache": false,
            "showTemperatureAndHumidity": true,
            "enableValveControl": true,
            "showHealthTestSwitch": true,
            "treatWarningAsCritical": false,
            "deviceRefresh": 90,
            "offlineTimeLimit": 4,
            "sleepRevertMinutes": 120,
            "retryErrorDisplay": 3,
            "_bridge": {
                "username": "{{redacted}}",
                "port": 56175
            },
            "platform": "Flo-by-Moen"
        }
    ],
    "disabledPlugins": []
}

Screenshots:

Screenshot 2024-05-29 at 12 31 12 PM

Environment: Homebridge running in a Docker container on an x86 server.

haywirecoder commented 3 months ago

Can you enable debugging and provide the output? Is this a new device?

jryburn commented 3 months ago

Wow. Turning on debug actually got it working. It is a new device. Here are the logs:


[5/29/2024, 10:47:56 PM] [Flo-by-Moen] Adding Device:  {
  name: '3/4” Smart Water Shutoff',
  deviceModel: 'flo_device_075_v2',
  type: 'flo_device_v2',
  serialNumber: 'NA',
  location: '3237a7a1-f0c7-4c96-b6d2-c31ec13e5b00',
  deviceid: '58fa1611-a8e5-4955-ad6b-67ebd142383b',
  notifications: {
    infoCount: 0,
    warningCount: 0,
    criticalCount: 0,
    alarmCount: [],
    info: { count: 0, devices: [Object] },
    warning: { count: 0, devices: [Object] },
    critical: { count: 0, devices: [Object] }
  },
  warningCount: 0,
  criticalCount: 0,
  version: '7.1.5',
  isConnected: true,
  offline: 0,
  errorCount: 0,
  lastUpdate: 2024-05-30T03:46:00.000Z,
  psi: 49.20000076293945,
  gpm: 0,
  systemCurrentState: 'sleep',
  systemTargetState: 'sleep',
  valveCurrentState: 'open',
  valveTargetState: 'open',
  isInstalled: true
}
[5/29/2024, 10:47:56 PM] [Flo-by-Moen] Add accessory
[5/29/2024, 10:47:56 PM] [Flo-by-Moen] Add accessory
[5/29/2024, 10:47:56 PM] [Flo-by-Moen] Flo device updates complete, background polling process started.
Device will be polled each 1 min(s) 30 second(s).
[5/29/2024, 10:49:26 PM] [Flo-by-Moen] Getting Update time  3/4” Smart Water Shutoff
[5/29/2024, 10:49:26 PM] [Flo-by-Moen] Comparing update time for  3/4” Smart Water Shutoff
[5/29/2024, 10:49:26 PM] [Flo-by-Moen] Device Updated Data:  {
[5/29/2024, 10:49:26 PM] [Flo-by-Moen] Updating homekit for   3/4” Smart Water Shutoff
[5/29/2024, 10:49:26 PM] [Flo-by-Moen] Device updated requested:  {
[5/29/2024, 10:49:43 PM] [Flo-by-Moen] Flo Valve Now:  closed
[5/29/2024, 10:49:43 PM] [Flo-by-Moen] {
[5/29/2024, 10:49:54 PM] [Flo-by-Moen] Error: Request failed with status code 409
[5/29/2024, 10:50:21 PM] [Flo-by-Moen] Error: Request failed with status code 409
[5/29/2024, 10:50:35 PM] [Flo-by-Moen] Error: Request failed with status code 409
[5/29/2024, 10:50:46 PM] [Flo-by-Moen] Flo Health: Running Health Check. This will take up to 4 mins.
[5/29/2024, 10:50:47 PM] [Flo-by-Moen] Error: Request failed with status code 403
[5/29/2024, 10:50:57 PM] [Flo-by-Moen] Getting Update time  3/4” Smart Water Shutoff
[5/29/2024, 10:50:57 PM] [Flo-by-Moen] Comparing update time for  3/4” Smart Water Shutoff
[5/29/2024, 10:50:57 PM] [Flo-by-Moen] Device Updated Data:  {
[5/29/2024, 10:50:57 PM] [Flo-by-Moen] Updating homekit for   3/4” Smart Water Shutoff
[5/29/2024, 10:50:57 PM] [Flo-by-Moen] Device updated requested:  {
[5/29/2024, 10:50:57 PM] [Flo-by-Moen] Flo Valve Now:  open
[5/29/2024, 10:50:57 PM] [Flo-by-Moen] {

Maybe it was the restarting of Homebridge that got it going. Either way, I will close the issue as I cannot reproduce it now and all seems fine.