derek-miller / homebridge-unifi-smartpower

Homebridge UniFi SmartPower Plugin
Apache License 2.0
7 stars 1 forks source link

1.0.0 Unable to find Outlets #17

Closed cjsfj closed 1 year ago

cjsfj commented 1 year ago

Describe The Bug:

When upgrading to 1.0.0, the plugin was unable to find any outlets. Rolling back to 0.4.3 fixed the issue.

To Reproduce:

Upgrade to 1.0.0

Expected behavior:

1.0.0 should list outlets

Logs:

[1/19/2023, 4:01:46 PM] [UniFi SmartPower] Failed to get status from UniFi; verify host, port, username, and password are correct:  TypeError: Cannot read properties of undefined (reading 'find')
    at /opt/homebrew/lib/node_modules/homebridge-unifi-smartpower/src/uniFiSmartPower.ts:253:42
    at Array.map (<anonymous>)
    at Function.transformDeviceStatusResponse (/opt/homebrew/lib/node_modules/homebridge-unifi-smartpower/src/uniFiSmartPower.ts:236:12)
    at /opt/homebrew/lib/node_modules/homebridge-unifi-smartpower/src/uniFiSmartPower.ts:203:46
    at Array.map (<anonymous>)
    at /opt/homebrew/lib/node_modules/homebridge-unifi-smartpower/src/uniFiSmartPower.ts:203:14
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Plugin Config:

        {
            "name": "UniFi SmartPower",
            "host": "192.168.2.1",
            "port": 443,
            "username": "homebridge",
            "password": "<password>",
            "includeInactivePorts": false,
            "refreshDevicesPollInterval": 600,
            "outletStatusCacheTtl": 15,
            "outletStatusPollInterval": 15,
            "_bridge": {
                "username": "0E:E2:CE:5B:7C:CB",
                "port": 48525
            },
            "platform": "UniFiSmartPower"
        }

Screenshots:

n/a

Environment:

derek-miller commented 1 year ago

Ah, I didn’t account for the “No Switch Port/ Outlet Overrides” case. I will fix this and get it out tomorrow.

derek-miller commented 1 year ago

This should be resolved in v1.0.1 🤞🏻

cjsfj commented 1 year ago

@derek-miller Receiving the following error from the plugin in 1.0.1:


[1/20/2023, 1:53:34 PM] [UniFi SmartPower] Outlet [FCECDA7612D3.1]: undefined > undefined
AssertionError [ERR_ASSERTION]: Accessories must be created with a non-empty displayName.
    at new Accessory (/opt/homebrew/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:491:11)
    at new PlatformAccessory (/opt/homebrew/lib/node_modules/homebridge/src/platformAccessory.ts:71:9)
    at UniFiSmartPowerHomebridgePlatform.discoverDevices (/opt/homebrew/lib/node_modules/homebridge-unifi-smartpower/src/platform.ts:95:30)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at HomebridgeAPI.refreshDevices (/opt/homebrew/lib/node_modules/homebridge-unifi-smartpower/src/platform.ts:52:7)```
derek-miller commented 1 year ago

Can you upgrade to v1.0.3 and set the logApiResponses to true in the config, then paste back here the output? There must be some case Im not accounting for.

cjsfj commented 1 year ago

[1/21/2023, 10:54:16 AM] [UniFi SmartPower] Launched child bridge with PID 91098
[1/21/2023, 10:54:16 AM] Registering platform 'homebridge-unifi-smartpower.UniFiSmartPower'
[1/21/2023, 10:54:16 AM] [UniFi SmartPower] Loaded homebridge-unifi-smartpower v1.0.3 child bridge successfully
[1/21/2023, 10:54:16 AM] Loaded 2 cached accessories from cachedAccessories.0EE2CE5B7CCB.
[1/21/2023, 10:54:16 AM] [UniFi SmartPower] Loading accessory from cache: UniFi SmartPower
[1/21/2023, 10:54:16 AM] [UniFi SmartPower] Loading accessory from cache: UniFi SmartPower
[1/21/2023, 10:54:16 AM] Homebridge v1.6.0 (HAP v0.11.0) (UniFi SmartPower) is running on port 48525.
[1/21/2023, 10:54:16 AM] [UniFi SmartPower] SITES:  [
  {
    "id": "default",
    "name": "Default"
  }
]
[1/21/2023, 10:54:16 AM] [UniFi SmartPower] Site [default]: Default
[1/21/2023, 10:54:17 AM] [UniFi SmartPower] SITE: %S DEVICES: default [
  {
    "device": {
      "site": "default",
      "id": "5f491a32d4701e027c978d63",
      "ip": "192.168.3.54",
      "mac": "e0:63:da:c8:2a:40",
      "model": "US8P60",
      "version": "6.4.18.14328",
      "serialNumber": "E063DAC82A40",
      "name": "US 8 POE - Office"
    },
    "ports": [
      {
        "index": 5,
        "name": "Port 5",
        "poeMode": "auto",
        "inUse": -1,
        "active": false,
        "poeOnAction": "auto",
        "entry": {
          "port_idx": 5,
          "media": "GE",
          "port_poe": true,
          "poe_caps": 1,
          "speed_caps": 1048623,
          "op_mode": "switch",
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "auto",
          "name": "Port 5",
          "enable": true,
          "masked": false,
          "aggregated_by": false
        },
        "override": {
          "port_idx": 5,
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "auto",
          "name": "Port 5"
        }
      },
      {
        "index": 6,
        "name": "Port 6",
        "poeMode": "auto",
        "inUse": -1,
        "active": false,
        "poeOnAction": "auto",
        "entry": {
          "port_idx": 6,
          "media": "GE",
          "port_poe": true,
          "poe_caps": 1,
          "speed_caps": 1048623,
          "op_mode": "switch",
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "auto",
          "name": "Port 6",
          "enable": true,
          "masked": false,
          "aggregated_by": false
        },
        "override": {
          "port_idx": 6,
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "auto",
          "name": "Port 6"
        }
      },
      {
        "index": 7,
        "name": "Port 7",
        "poeMode": "auto",
        "inUse": -1,
        "active": false,
        "poeOnAction": "auto",
        "entry": {
          "port_idx": 7,
          "media": "GE",
          "port_poe": true,
          "poe_caps": 1,
          "speed_caps": 1048623,
          "op_mode": "switch",
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "auto",
          "name": "Port 7",
          "enable": true,
          "masked": false,
          "aggregated_by": false
        },
        "override": {
          "port_idx": 7,
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "auto",
          "name": "Port 7"
        }
      },
      {
        "index": 8,
        "name": "Port 8",
        "poeMode": "auto",
        "inUse": -1,
        "active": false,
        "poeOnAction": "auto",
        "entry": {
          "port_idx": 8,
          "media": "GE",
          "port_poe": true,
          "poe_caps": 1,
          "speed_caps": 1048623,
          "op_mode": "switch",
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "auto",
          "name": "Port 8",
          "enable": true,
          "masked": false,
          "aggregated_by": false
        },
        "override": {
          "port_idx": 8,
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "auto",
          "name": "Port 8"
        }
      }
    ],
    "outlets": []
  },
  {
    "device": {
      "site": "default",
      "id": "61974a450d9c5177f398c37b",
      "ip": "192.168.2.189",
      "mac": "fc:ec:da:76:12:d3",
      "model": "UP1",
      "version": "2.2.3.519",
      "serialNumber": "FCECDA7612D3"
    },
    "ports": [],
    "outlets": [
      {
        "index": 1,
        "name": "Outlet 1",
        "relayState": 1,
        "inUse": -1,
        "entry": {
          "index": 1,
          "has_relay": true,
          "has_metering": false,
          "relay_state": true,
          "name": "Outlet 1"
        },
        "override": {
          "index": 1,
          "name": "Outlet 1",
          "relay_state": true
        }
      }
    ]
  },
  {
    "device": {
      "site": "default",
      "id": "6359b295af74f6094ee279b9",
      "ip": "192.168.2.119",
      "mac": "70:a7:41:a2:7f:be",
      "model": "US68P",
      "version": "6.4.18.14328",
      "serialNumber": "70A741A27FBE",
      "name": "USW-Enterprise-8-PoE"
    },
    "ports": [
      {
        "index": 1,
        "name": "Synology",
        "poeMode": "off",
        "inUse": 0,
        "active": false,
        "poeOnAction": "auto",
        "entry": {
          "port_idx": 1,
          "media": "2P5GE",
          "port_poe": true,
          "poe_caps": 3,
          "speed_caps": 1048680,
          "op_mode": "aggregate",
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "off",
          "aggregate_num_ports": 4,
          "autoneg": true,
          "dot1x_mode": "force_auth",
          "dot1x_status": "authorized",
          "enable": true,
          "flowctrl_rx": false,
          "flowctrl_tx": false,
          "full_duplex": true,
          "is_uplink": false,
          "jumbo": true,
          "lacp_state": [
            {
              "active": true,
              "member_port": 1,
              "speed": 1000
            },
            {
              "active": true,
              "member_port": 2,
              "speed": 1000
            },
            {
              "active": true,
              "member_port": 3,
              "speed": 1000
            },
            {
              "active": true,
              "member_port": 4,
              "speed": 1000
            }
          ],
          "lag_member": true,
          "mac_table": [
            {
              "age": 55,
              "hostname": "James",
              "ip": "192.168.2.5",
              "mac": "00:11:32:40:38:4d",
              "static": false,
              "uptime": 955003,
              "vlan": 1,
              "port_delta": {
                "time_delta": 53,
                "time_delta_activity": 53,
                "tx_bytes": 199047,
                "rx_bytes": 180254708,
                "tx_packets": 604,
                "rx_packets": 23
              },
              "is_only_station_on_port": true
            }
          ],
          "partner_system_id": "00:00:00:00:00:00",
          "poe_class": "Unknown",
          "poe_current": "0.00",
          "poe_enable": false,
          "poe_good": false,
          "poe_power": "0.00",
          "poe_voltage": "0.00",
          "rx_broadcast": 0,
          "rx_bytes": 347738867135,
          "rx_dropped": 0,
          "rx_errors": 0,
          "rx_multicast": 31815,
          "rx_packets": 31815,
          "satisfaction": 100,
          "satisfaction_reason": 0,
          "service_mac_table": [],
          "speed": 1000,
          "stp_pathcost": 10000,
          "stp_state": "forwarding",
          "tx_broadcast": 2604864,
          "tx_bytes": 494657122596,
          "tx_dropped": 0,
          "tx_errors": 0,
          "tx_multicast": 3398852,
          "tx_packets": 6003716,
          "up": true,
          "tx_bytes-r": 142583,
          "rx_bytes-r": 7,
          "bytes-r": 142590,
          "name": "Synology",
          "port_security_mac_address": [],
          "port_security_enabled": false,
          "masked": false,
          "aggregated_by": false
        },
        "override": {
          "name": "Synology",
          "port_idx": 1,
          "poe_mode": "off",
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "op_mode": "aggregate",
          "port_security_mac_address": [],
          "autoneg": true,
          "aggregate_num_ports": 4,
          "port_security_enabled": false
        }
      },
      {
        "index": 2,
        "name": "Port 2",
        "poeMode": "auto",
        "inUse": 0,
        "active": false,
        "poeOnAction": "auto",
        "entry": {
          "port_idx": 2,
          "media": "2P5GE",
          "port_poe": true,
          "poe_caps": 3,
          "speed_caps": 1048680,
          "op_mode": "switch",
          "portconf_id": "5dcadb09aeb21c05022dfd4e",
          "poe_mode": "auto",
          "autoneg": true,
          "dot1x_mode": "force_auth",
          "AssertionError [ERR_ASSERTION]: Accessories must be created with a non-empty displayName.
    at new Accessory (/opt/homebrew/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:491:11)
    at new PlatformAccessory (/opt/homebrew/lib/node_modules/homebridge/src/platformAccessory.ts:71:9)
    at UniFiSmartPowerHomebridgePlatform.discoverDevices (/opt/homebrew/lib/node_modules/homebridge-unifi-smartpower/src/platform.ts:129:32)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at HomebridgeAPI.refreshDevices (/opt/homebrew/lib/node_modules/homebridge-unifi-smartpower/src/platform.ts:60:7)
[1/21/2023, 10:54:17 AM] [UniFi SmartPower] Child bridge process ended
[1/21/2023, 10:54:17 AM] [UniFi SmartPower] Process Ended. Code: 1, Signal: null
derek-miller commented 1 year ago

Ok, try v1.0.4