<commit_before>import express = require('express');
import IRelay = require('./gpio/IRelay');
import RaspberryPiRelay = require('./gpio/RaspberryPiRelay');
var Gpio = require('onoff').Gpio;
var noble = require('noble');

var app = express();
app.get('/v1/ping', require('./route/ping'));

var openGarage = {
	activateDurationInSeconds: 1,
	gpioOutputPin: 25
};

var switchLight = {
	activateDurationInSeconds: 60,
	gpioOutputPin: 17
}
var garageRelay = new Gpio(switchLight.gpioOutputPin, 'out');
var switchLightRelay = new IRelay.DebounceRelay(switchLight, (state) => {
	console.log('Switch Light: ' + state ? "On": "Off" );
	garageRelay.writeSync(state ? 1 : 0);
});

var doorSwitch = new Gpio(21, 'in', 'both');

doorSwitch.watch((error, value) => {
	log("doorSwitch watch updated: " + value);
	switchLightRelay.switchOn();
});

app.get('/v1/garage/state', (request, response) => {
	var doorSwitchState = doorSwitch.readSync();
	response.send({
		timestamp: new Date(),
		isOpen: (doorSwitchState == 0) ? false : true
	});
});

app.get('/v1/garage/toggle/', (request, response) => {
	RaspberryPiRelay.executeCommand(openGarage);
	switchLightRelay.switchOn();
	response.send('successfull');
});

app.listen(3000, function () {<commit_msg>test debounce on watching the GPIO input<commit_after>import express = require('express');
import _ = require('lodash');

import IRelay = require('./gpio/IRelay');
import RaspberryPiRelay = require('./gpio/RaspberryPiRelay');
var Gpio = require('onoff').Gpio;
var noble = require('noble');

var app = express();
app.get('/v1/ping', require('./route/ping'));

var openGarage = {
	activateDurationInSeconds: 1,
	gpioOutputPin: 25
};

var switchLight = {
	activateDurationInSeconds: 60,
	gpioOutputPin: 17
}
var garageRelay = new Gpio(switchLight.gpioOutputPin, 'out');
garageRelay.writeSync(0);

var switchLightRelay = new IRelay.DebounceRelay(switchLight, (state) => {
	console.log('Switch Light: ' + state ? "On": "Off" );
	garageRelay.writeSync(state ? 1 : 0);
});

var doorSwitch = new Gpio(21, 'in', 'both');

doorSwitch.watch( _.debounce((error, value) => {
	log("doorSwitch watch updated: " + value);
	switchLightRelay.switchOn();
}, 15*1000, {
  'leading': true,
  'trailing': false
}));

app.get('/v1/garage/state', (request, response) => {
	var doorSwitchState = doorSwitch.readSync();
	response.send({
		timestamp: new Date(),
		isOpen: (doorSwitchState == 0) ? false : true
	});
});

app.get('/v1/garage/toggle/', (request, response) => {
	RaspberryPiRelay.executeCommand(openGarage);
	switchLightRelay.switchOn();
	response.send('successfull');
});

app.listen(3000, function () {
{'fraction_non_alphanumeric': 0.1782592170277461, 'fraction_numerical': 0.01710376282782212, 'mean_word_length': 5.54726368159204, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '760733', 'n_tokens_mistral': 945, 'n_tokens_neox': 901, 'n_words': 187}