ankurp / homebridge-pi-thermostat

Homebridge Plugin to make Raspberry Pi into Thermostat
https://www.npmjs.com/package/homebridge-pi-thermostat
39 stars 23 forks source link

Invert gpio #6

Closed riddik14 closed 5 years ago

riddik14 commented 6 years ago

Hi how I can invert gpio state?

ankurp commented 5 years ago

You can search online for inverting but the way this homebridge plugin is setup, turning on the relay Pin will turn on the relay switch and it will cause the current to flow between the Red and which ever wire it is connected to.

wsmeyer90277 commented 5 years ago

I had the same problem. Maybe creator used relays that triggered low?

You can invert them by opening index.js file and changing:

let Service, Characteristic, HeatingCoolingStateToRelayPin;
const OFF = true;
const ON = false;

TO:

let Service, Characteristic, HeatingCoolingStateToRelayPin;
const OFF = false;
const ON = true;

AND

gpio.setup(this.fanRelayPin, gpio.DIR_HIGH);
gpio.setup(this.heatRelayPin, gpio.DIR_HIGH);
gpio.setup(this.coolRelayPin, gpio.DIR_HIGH);

TO:

gpio.setup(this.fanRelayPin, gpio.DIR_LOW);
gpio.setup(this.heatRelayPin, gpio.DIR_LOW);
gpio.setup(this.coolRelayPin, gpio.DIR_LOW);