Skip to content

Commit

Permalink
Update RpiPlatform.js
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
ebaauw committed Nov 11, 2023
1 parent 0dc9546 commit 8a825be
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/RpiPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class RpiPlatform extends homebridgeLib.Platform {
.stringKey('name')
.hostKey()
.boolKey('hidden')
.boolKey('noFan')
.boolKey('noPowerLed')
.boolKey('noSmokeSensor')
.boolKey('usbPower')
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit 8a825be

Please sign in to comment.