vectronic / homebridge-nut

Homebridge plugin for NUT (Network UPS Tools) Client
19 stars 3 forks source link

UUID collision #4

Closed benbrookshire closed 3 years ago

benbrookshire commented 3 years ago

Hi, trying out your plugin with an Eaton UPS, getting a conflict that prevents both the ContactService and BatteryService from being created.

On a fresh install of the plugin, you can see the first "adding new accessory" seems to proceed, but on the following attempt there is a failure:

[22/08/2021, 13:27:16] [Nut] starting nut client for localhost:3493
[22/08/2021, 13:27:16] [Nut] nut client connected, reported devices: eaton=Eaton 3S UPS
[22/08/2021, 13:28:11] [Nut] adding new accessory: Eaton 3S UPS
[22/08/2021, 13:45:11] [Nut] adding new accessory: Eaton 3S UPS
[22/08/2021, 13:45:11] [Nut] error invoking GetUPSVars on nut client for device eaton=Eaton 3S UPS: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: <cedxxxx6-xxx-4e09-xxxx-1e318xxxxbb2>

Both devices are showing up in the Homebridge UI under Accessories, but this error appears to prevent the BatteryService from showing up in the Home app.

Any ideas on how to get around this? I couldn't find a way to manually set the accessory names to avoid the collision, but reading your README its obvious that both accessories are supposed to be there.

vectronic commented 3 years ago

Hello, I will look into this in the next few days.

vectronic commented 3 years ago

Hello,

I've had a look at this and can't really see what is happening without debug logging enabled. If you could start Homebridge with debug logging enabled and provide all of the [Nut] entries I will be able to see more of what is going on.

Just to clarify:

I can't determine from your description if you have 1 or 2 UPS devices...?

benbrookshire commented 3 years ago

Hello, thanks for taking a look regarding my issue. Unless I have misconfigured Nut, it should be reporting on a single physical UPS device (i.e. I only have one UPS device in play, here). I have not previously had 2 devices on my network, or attempted to configure Nut with more than one physical UPS device. So I think the error I'm seeing may relate to the two accessories - ContactService and BatteryService.

Here's the log entries with Homebridge in debug mode at startup:

[05/09/2021, 13:42:52] [HB Supervisor] Restarting Homebridge...
[05/09/2021, 13:42:52] [HB Supervisor] Starting Homebridge with extra flags: -I -D
[05/09/2021, 13:42:52] [HB Supervisor] Started Homebridge v1.3.2 with PID: 12819
Initializing HAP-NodeJS v0.9.2...
[05/09/2021, 13:42:54] Loaded config.json with 0 accessories and 6 platforms.
[05/09/2021, 13:42:54] Loaded 3 cached accessories from cachedAccessories.
[05/09/2021, 13:42:56] ---
[05/09/2021, 13:42:56] Loaded plugin: homebridge-config-ui-x@4.41.1
[05/09/2021, 13:42:56] Registering platform 'homebridge-config-ui-x.config'
[05/09/2021, 13:42:56] ---
[05/09/2021, 13:42:57] Loaded plugin: @vectronic/homebridge-nut@2.1.1
[05/09/2021, 13:42:57] Registering platform '@vectronic/homebridge-nut.Nut'
[05/09/2021, 13:42:57] ---
[05/09/2021, 13:42:57] Loading 6 platforms...
[05/09/2021, 13:42:57] [Config] Initializing config platform...
[05/09/2021, 13:42:57] [Config] Running in Service Mode
[05/09/2021, 13:42:57] [Nut] Initializing Nut platform...
[05/09/2021, 13:42:57] [Nut] finished initializing platform
[05/09/2021, 13:42:57] [Nut] didFinishLaunching callback
[05/09/2021, 13:42:57] [Nut] created nut client for localhost:3493
[05/09/2021, 13:42:57] [Nut] startPolling()
[05/09/2021, 13:43:02] [Nut] starting nut client for localhost:3493
[05/09/2021, 13:43:02] [Nut] nutReady()
[05/09/2021, 13:43:02] [Nut] nut client connected, reported devices: eaton=Eaton 3S UPS
[05/09/2021, 13:43:57] [Nut] pollNutDevices()
[05/09/2021, 13:43:57] [Nut] pollNutDevice(eaton, Eaton 3S UPS)
[05/09/2021, 13:43:57] [Nut] parseUpsVars(eaton)
[05/09/2021, 13:43:57] [Nut] UPS info for device: eaton=Eaton 3S UPS =>
[05/09/2021, 13:43:57] [Nut] battery.charge=100
[05/09/2021, 13:43:57] [Nut] battery.charge.low=20
[05/09/2021, 13:43:57] [Nut] battery.runtime=3000
[05/09/2021, 13:43:57] [Nut] battery.type=PbAc
[05/09/2021, 13:43:57] [Nut] device.mfr=EATON
[05/09/2021, 13:43:57] [Nut] device.model=Eaton 3S 550
[05/09/2021, 13:43:57] [Nut] device.serial=000000000
[05/09/2021, 13:43:57] [Nut] device.type=ups
[05/09/2021, 13:43:57] [Nut] driver.name=usbhid-ups
[05/09/2021, 13:43:57] [Nut] driver.parameter.pollfreq=30
[05/09/2021, 13:43:57] [Nut] driver.parameter.pollinterval=2
[05/09/2021, 13:43:57] [Nut] driver.parameter.port=auto
[05/09/2021, 13:43:57] [Nut] driver.parameter.synchronous=no
[05/09/2021, 13:43:57] [Nut] driver.version=2.7.4
[05/09/2021, 13:43:57] [Nut] driver.version.data=MGE HID 1.39
[05/09/2021, 13:43:57] [Nut] driver.version.internal=0.41
[05/09/2021, 13:43:57] [Nut] input.transfer.high=138
[05/09/2021, 13:43:57] [Nut] input.transfer.low=96
[05/09/2021, 13:43:57] [Nut] outlet.1.desc=PowerShare Outlet 1
[05/09/2021, 13:43:57] [Nut] outlet.1.id=2
[05/09/2021, 13:43:57] [Nut] outlet.1.status=on
[05/09/2021, 13:43:57] [Nut] outlet.1.switchable=yes
[05/09/2021, 13:43:57] [Nut] outlet.2.desc=PowerShare Outlet 2
[05/09/2021, 13:43:57] [Nut] outlet.2.id=3
[05/09/2021, 13:43:57] [Nut] outlet.2.status=off
[05/09/2021, 13:43:57] [Nut] outlet.2.switchable=yes
[05/09/2021, 13:43:57] [Nut] outlet.desc=Main Outlet
[05/09/2021, 13:43:57] [Nut] outlet.id=1
[05/09/2021, 13:43:57] [Nut] outlet.switchable=no
[05/09/2021, 13:43:57] [Nut] output.frequency.nominal=60
[05/09/2021, 13:43:57] [Nut] output.voltage=115.0
[05/09/2021, 13:43:57] [Nut] output.voltage.nominal=115
[05/09/2021, 13:43:57] [Nut] ups.beeper.status=enabled
[05/09/2021, 13:43:57] [Nut] ups.delay.shutdown=20
[05/09/2021, 13:43:57] [Nut] ups.delay.start=30
[05/09/2021, 13:43:57] [Nut] ups.firmware=02
[05/09/2021, 13:43:57] [Nut] ups.load=0
[05/09/2021, 13:43:57] [Nut] ups.mfr=EATON
[05/09/2021, 13:43:57] [Nut] ups.model=Eaton 3S 550
[05/09/2021, 13:43:57] [Nut] ups.power.nominal=550
[05/09/2021, 13:43:57] [Nut] ups.productid=ffff
[05/09/2021, 13:43:57] [Nut] ups.serial=000000000
[05/09/2021, 13:43:57] [Nut] ups.status=OL
[05/09/2021, 13:43:57] [Nut] ups.timer.shutdown=-1
[05/09/2021, 13:43:57] [Nut] ups.timer.start=-1
[05/09/2021, 13:43:57] [Nut] ups.vendorid=0463
[05/09/2021, 13:43:57] [Nut] parsed UPS values: {"key":"eaton","name":"Eaton 3S UPS","fault":false,"active":false,"onBattery":false,"temperature":-1,"batteryLevel":100,"chargingState":1,"lowBattery":false,"powerConsumption":0,"powerConsumptionLevel":0,"manufacturer":"EATON","model":"Eaton 3S 550","serialNumber":"000000000","firmwareRevision":"02"}
[05/09/2021, 13:43:57] [Nut] createOrUpdateUps(): eaton
[05/09/2021, 13:43:57] [Nut] adding new accessory: Eaton 3S UPS
[05/09/2021, 13:43:57] [Nut] update()
[05/09/2021, 13:43:57] [Nut] pushed changed UPS state to HomeKit for eaton=Eaton 3S UPS
[05/09/2021, 13:44:57] [Nut] pollNutDevices()
[05/09/2021, 13:44:57] [Nut] pollNutDevice(eaton, Eaton 3S UPS)
[05/09/2021, 13:44:57] [Nut] parseUpsVars(eaton)
[05/09/2021, 13:44:57] [Nut] UPS info for device: eaton=Eaton 3S UPS =>
[05/09/2021, 13:44:57] [Nut] battery.charge=100
[05/09/2021, 13:44:57] [Nut] battery.charge.low=20
[05/09/2021, 13:44:57] [Nut] battery.runtime=3000
[05/09/2021, 13:44:57] [Nut] battery.type=PbAc
[05/09/2021, 13:44:57] [Nut] device.mfr=EATON
[05/09/2021, 13:44:57] [Nut] device.model=Eaton 3S 550
[05/09/2021, 13:44:57] [Nut] device.serial=000000000
[05/09/2021, 13:44:57] [Nut] device.type=ups
[05/09/2021, 13:44:57] [Nut] driver.name=usbhid-ups
[05/09/2021, 13:44:57] [Nut] driver.parameter.pollfreq=30
[05/09/2021, 13:44:57] [Nut] driver.parameter.pollinterval=2
[05/09/2021, 13:44:57] [Nut] driver.parameter.port=auto
[05/09/2021, 13:44:57] [Nut] driver.parameter.synchronous=no
[05/09/2021, 13:44:57] [Nut] driver.version=2.7.4
[05/09/2021, 13:44:57] [Nut] driver.version.data=MGE HID 1.39
[05/09/2021, 13:44:57] [Nut] driver.version.internal=0.41
[05/09/2021, 13:44:57] [Nut] input.transfer.high=138
[05/09/2021, 13:44:57] [Nut] input.transfer.low=96
[05/09/2021, 13:44:57] [Nut] outlet.1.desc=PowerShare Outlet 1
[05/09/2021, 13:44:57] [Nut] outlet.1.id=2
[05/09/2021, 13:44:57] [Nut] outlet.1.status=on
[05/09/2021, 13:44:57] [Nut] outlet.1.switchable=yes
[05/09/2021, 13:44:57] [Nut] outlet.2.desc=PowerShare Outlet 2
[05/09/2021, 13:44:57] [Nut] outlet.2.id=3
[05/09/2021, 13:44:57] [Nut] outlet.2.status=off
[05/09/2021, 13:44:57] [Nut] outlet.2.switchable=yes
[05/09/2021, 13:44:57] [Nut] outlet.desc=Main Outlet
[05/09/2021, 13:44:57] [Nut] outlet.id=1
[05/09/2021, 13:44:57] [Nut] outlet.switchable=no
[05/09/2021, 13:44:57] [Nut] output.frequency.nominal=60
[05/09/2021, 13:44:57] [Nut] output.voltage=115.0
[05/09/2021, 13:44:57] [Nut] output.voltage.nominal=115
[05/09/2021, 13:44:57] [Nut] ups.beeper.status=enabled
[05/09/2021, 13:44:57] [Nut] ups.delay.shutdown=20
[05/09/2021, 13:44:57] [Nut] ups.delay.start=30
[05/09/2021, 13:44:57] [Nut] ups.firmware=02
[05/09/2021, 13:44:57] [Nut] ups.load=6
[05/09/2021, 13:44:57] [Nut] ups.mfr=EATON
[05/09/2021, 13:44:57] [Nut] ups.model=Eaton 3S 550
[05/09/2021, 13:44:57] [Nut] ups.power.nominal=550
[05/09/2021, 13:44:57] [Nut] ups.productid=ffff
[05/09/2021, 13:44:57] [Nut] ups.serial=000000000
[05/09/2021, 13:44:57] [Nut] ups.status=OL
[05/09/2021, 13:44:57] [Nut] ups.timer.shutdown=-1
[05/09/2021, 13:44:57] [Nut] ups.timer.start=-1
[05/09/2021, 13:44:57] [Nut] ups.vendorid=0463
[05/09/2021, 13:44:57] [Nut] parsed UPS values: {"key":"eaton","name":"Eaton 3S UPS","fault":false,"active":true,"onBattery":false,"temperature":-1,"batteryLevel":100,"chargingState":1,"lowBattery":false,"powerConsumption":26,"powerConsumptionLevel":6,"manufacturer":"EATON","model":"Eaton 3S 550","serialNumber":"000000000","firmwareRevision":"02"}
[05/09/2021, 13:44:57] [Nut] createOrUpdateUps(): eaton
[05/09/2021, 13:44:57] [Nut] adding new accessory: Eaton 3S UPS
[05/09/2021, 13:44:57] [Nut] error invoking GetUPSVars on nut client for device eaton=Eaton 3S UPS: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: ced0c686-e8d0-4e09-9042-1e31883adbb2

Is the below what you're wanting to see, regarding Nut config?

# upsc eaton
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 20
battery.runtime: 3000
battery.type: PbAc
device.mfr: EATON
device.model: Eaton 3S 550
device.serial: 000000000
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: MGE HID 1.39
driver.version.internal: 0.41
input.transfer.high: 138
input.transfer.low: 96
outlet.1.desc: PowerShare Outlet 1
outlet.1.id: 2
outlet.1.status: on
outlet.1.switchable: yes
outlet.2.desc: PowerShare Outlet 2
outlet.2.id: 3
outlet.2.status: off
outlet.2.switchable: yes
outlet.desc: Main Outlet
outlet.id: 1
outlet.switchable: no
output.frequency.nominal: 60
output.voltage: 115.0
output.voltage.nominal: 115
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.firmware: 02
ups.load: 0
ups.mfr: EATON
ups.model: Eaton 3S 550
ups.power.nominal: 550
ups.productid: ffff
ups.serial: 000000000
ups.status: OL
ups.timer.shutdown: -1
ups.timer.start: -1
ups.vendorid: 0463

/etc/nut/ups.conf

maxretry = 3

[eaton]
        driver = usbhid-ups
        port = auto
        desc = "Eaton 3S UPS"

/etc/nut/nut.conf

MODE=standalone
vectronic commented 3 years ago

Thanks for the logs and clarification- I’ll check it out in the next few days.

vectronic commented 3 years ago

I've pushed a new version (2.1.2) which should fix the erroneous behaviour of trying to add an already added an accessory. So you should no longer see the error in the logs...

However, thinking more about your description, maybe the behaviour of the Home App is confusing you. I think (I could be wrong on all of this) Apple changed the UI a year or so ago: the contact sensor and battery sensor now appear unified in a single accessory.

See the screenshot attached (taken from the macOS Home app). In the background you can see one accessory "Eaton" (closed) but when looking at the details for it in the foreground you can see both the "Contact Sensor State" AND the Battery "Status".

home
benbrookshire commented 3 years ago

Pulled the new version and it looks ok, now. No longer seeing the error. I noticed it was looping and causing Homebridge to sigterm, previously. No longer happening. Thanks for resolving for me.

FF183D1C-E384-401F-A459-B756F7CA8AD6