jak / homebridge-unifi-firewall

A switch for enabling or disabling a firewall rule on Ubiquiti Unifi for guests/kids/etc
Apache License 2.0
0 stars 1 forks source link

TypeError: Cannot read properties of undefined (reading 'Service') #1

Closed llajas closed 1 year ago

llajas commented 1 year ago

Describe The Bug:

Unable to add switch to config - Receiving an error that states the following during startup: TypeError: Cannot read properties of undefined (reading 'Service')

To Reproduce:

  1. Add plugin to HomeBridge
  2. Configure plugin settings
  3. Restart HomeBridge for settings to take affect
  4. Receive error above in logs and HomeBridge stops

Expected behavior:

  1. Add plugin to HomeBridge
  2. Configure plugin settings
  3. Restart HomeBridge for settings to take affect
  4. Setup complete and switch for plugin becomes visible in 'Accessories' and Homekit.

Logs:

[11/17/2022, 12:37:03 AM] [Homebridge Unifi Firewall Switch] Initializing UnifiFirewall accessory...
[11/17/2022, 12:37:04 AM] TypeError: Cannot read properties of undefined (reading 'Service')
    at new UnifiFirewallSwitch (/homebridge/node_modules/homebridge-unifi-firewall/src/accessory.ts:94:34)
    at /usr/local/lib/node_modules/homebridge/src/server.ts:378:50
    at Array.forEach (<anonymous>)
    at Server.loadAccessories (/usr/local/lib/node_modules/homebridge/src/server.ts:298:29)
    at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:179:12)

Plugin Config:

{
    "name": "Homebridge Unifi Firewall Switch",
    "controller": {
        "host": "10.0.0.1",
        "url": "https://10.0.0.1",
        "username": "LOCALUSER",
        "password": "mysecurepassword123",
        "strictSSL": false
    },
    "site": "5e3b75a0c8ae8702bc80f71a",
    "rule": "637550e01174220b4f78a9b8",
    "inverted": false,
    "accessory": "UnifiFirewall"
}

Screenshots:

image

Environment:

Thanks for your work on this - I've got a use case for this plugin, however after adding the configuration and restarting HomeBridge to apply I run into the above error. I'm not sure if this is related to my config, but I've included as much as I can for troubleshooting - For the site & rule ID's, I'm using scyto/docker-UnifiBrowser to get the values via the API.

Any help is appreciated - If this is related to my config, please let me know or if more info is needed! Thanks in advance for your time.

jak commented 1 year ago

Hey, the latest version should work as expected.

I threw this together for my own needs, didn't expect anyone to attempt to use it, so sorry for not seeing this issue until now.

Thank you for raising it with all the details 🙇