21 lines
438 B
JavaScript
21 lines
438 B
JavaScript
const { Gpio } = require('onoff');
|
|
const poll = require('./poll')
|
|
const common = require('./libs/common')
|
|
const globalVars = require('./libs/globalVars')
|
|
|
|
poll.setInterval
|
|
|
|
const switchIn = new Gpio('17', 'in', 'both');
|
|
|
|
switchIn.watch((err, value) => {
|
|
if (err) {
|
|
console.log('Error', err);
|
|
}
|
|
if (value === 1) {
|
|
if (globalVars.waterOn === 'true') {
|
|
common.request(0)
|
|
} else {
|
|
common.request(1)
|
|
}
|
|
}
|
|
}); |