From 8a825be9acb3f83d9ad68b4d20c85cb0329d623c Mon Sep 17 00:00:00 2001 From: ebaauw Date: Sat, 11 Nov 2023 12:14:31 +0100 Subject: [PATCH] Update RpiPlatform.js - Move powerLed and usbPower determination here (from hb-lib-tools); - Add support for fan on Pi 5; - Suppress GPIO devices on Pi 5, see #165. --- lib/RpiPlatform.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/RpiPlatform.js b/lib/RpiPlatform.js index 78d1eaf..bf6e241 100644 --- a/lib/RpiPlatform.js +++ b/lib/RpiPlatform.js @@ -49,6 +49,7 @@ class RpiPlatform extends homebridgeLib.Platform { .stringKey('name') .hostKey() .boolKey('hidden') + .boolKey('noFan') .boolKey('noPowerLed') .boolKey('noSmokeSensor') .boolKey('usbPower') @@ -308,11 +309,22 @@ class RpiPlatform extends homebridgeLib.Platform { if (cpuInfo.id === this.localId && host.name !== 'localhost') { this.log('%s: localhost', host.name) } - if (host.usbPower && !cpuInfo.usbPower) { + if (host.usbPower && !['B+', '2B', '3B', '3B+'].includes(cpuInfo.model)) { this.warn( '%s: Raspberry Pi %s: no USB power support', host.name, cpuInfo.model ) + host.usbPower = false + } + if (cpuInfo.model === '5' && host.devices.length > 0) { + this.warn('%s: Raspberry Pi %s: no GPIO support', host.name, cpuInfo.mode) + host.devices = [] + } + if (['A', 'B', 'Zero', 'Zero W', 'Zero 2 W', '5'].includes(cpuInfo.model)) { + host.noPowerLed = true + } + if (cpuInfo.model !== '5') { + host.noFan = true } const rpiAccessory = new RpiAccessory(this, { name: host.name, @@ -325,9 +337,10 @@ class RpiPlatform extends homebridgeLib.Platform { pi, gpioMask: cpuInfo.gpioMask, hidden: host.hidden, - noPowerLed: host.noPowerLed || !cpuInfo.powerLed, + noFan: host.noFan, + noPowerLed: host.noPowerLed, noSmokeSensor: host.noSmokeSensor, - usbPower: host.usbPower && cpuInfo.usbPower + usbPower: host.usbPower }) this.rpiAccessories[cpuInfo.id] = rpiAccessory for (const device of host.devices) {