Skip to content

Commit

Permalink
rollback RPIO polling fix
Browse files Browse the repository at this point in the history
  • Loading branch information
luis-godinez committed Aug 11, 2024
1 parent 2e4a9c9 commit 3b71eab
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ export class OpenSaunaAccessory {
}
}

// Monitor door states using GPIO
private monitorDoors() {
const doorSensors = [
{
Expand All @@ -576,7 +575,10 @@ export class OpenSaunaAccessory {

doorSensors.forEach(({ type, pin, inverse, allowOnWhileOpen, powerPins }) => {
if (pin !== undefined) {
// Set up polling with a callback function
// Remove existing poll if any
rpio.poll(pin, null);

// Set up polling with a callback function
rpio.poll(pin, () => {
const doorOpen = inverse ? rpio.read(pin) === 0 : rpio.read(pin) === 1;
this.platform.log.info(
Expand All @@ -603,7 +605,7 @@ export class OpenSaunaAccessory {
this.setPowerState(powerPins, false);
this.platform.log.warn(`${type} power off due to door open.`);
} else if (!doorOpen && !allowOnWhileOpen && powerPins) {
// Ensure the heater is resumed only when it was initially turned off due to the door open state
// Ensure the heater is resumed only when it was initially turned off due to the door open state
this.setPowerState(powerPins, true);
this.platform.log.info(`${type} power resumed as door closed.`);
}
Expand Down

0 comments on commit 3b71eab

Please sign in to comment.