index.js
/**
 * The main class acting as the garage door Accessory
 *
 * @param log The logger to use
 * @param config The config received from HomeBridge
 * @constructor
 */
The main class acting as the garage door Accessory
@param log The logger to use
@param config The config received from HomeBridge
@constructor
The main class acting as the garage door Accessory @param log The logger to use @param config The config received from HomeBridge @constructor
function HttpGarageDoorAccessory(log, config) {
	var self = this;
	self.log = log;
	self.name = config["name"];
	self.garagedoorService = null;
	self.debug = config.debug;
	self.polling = config.polling;
	self.pollInterval = config.pollInterval || 30000;
	self.previousCurrentState = null;
	self.previousTargetState = null;
	self.mappers = [];
	if (config.mappers) {
		config.mappers.forEach(function(matches) {
			switch (matches.type) {
				case "regex":
					self.mappers.push(new RegexMapper(matches.parameters));
					break;
				case "static":
					self.mappers.push(new StaticMapper(matches.parameters));
					break;
				case "xpath":
					self.mappers.push(new XPathMapper(matches.parameters));
					break;
			}
		});
	}
	self.urls = {
		readCurrentState: {
			url: config.urls.readCurrentState.url,
			body: config.urls.readCurrentState.body || ""
		},
		readTargetState: {
			url: config.urls.readTargetState.url,
			body: config.urls.readTargetState.body || ""
		},
		open: {
			url: config.urls.open.url,
			body: config.urls.open.body || ""
		},
		close: {
			url: config.urls.close.url,
			body: config.urls.close.body || ""
		}
	};
	self.httpMethod = config["http_method"] || "GET";
	self.auth = {
		username: config.username || "",
		password: config.password || "",
		immediately: true
	};
	if ("immediately" in config) {
		self.auth.immediately = config.immediately;
	}
	self.init();
}
function HttpGarageDoorAccessory ( log , config ) { var self = this ; self . log = log ; self . name = config [ "name" ] ; self . garagedoorService = null ; self . debug = config . debug ; self . polling = config . polling ; self . pollInterval = config . pollInterval || 30000 ; self . previousCurrentState = null ; self . previousTargetState = null ; self . mappers = [ ] ; if ( config . mappers ) { config . mappers . forEach ( function ( matches ) { switch ( matches . type ) { case "regex" : self . mappers . push ( new RegexMapper ( matches . parameters ) ) ; break ; case "static" : self . mappers . push ( new StaticMapper ( matches . parameters ) ) ; break ; case "xpath" : self . mappers . push ( new XPathMapper ( matches . parameters ) ) ; break ; } } ) ; } self . urls = { readCurrentState : { url : config . urls . readCurrentState . url , body : config . urls . readCurrentState . body || "" } , readTargetState : { url : config . urls . readTargetState . url , body : config . urls . readTargetState . body || "" } , open : { url : config . urls . open . url , body : config . urls . open . body || "" } , close : { url : config . urls . close . url , body : config . urls . close . body || "" } } ; self . httpMethod = config [ "http_method" ] || "GET" ; self . auth = { username : config . username || "" , password : config . password || "" , immediately : true } ; if ( "immediately" in config ) { self . auth . immediately = config . immediately ; } self . init ( ) ; }
The main class acting as the garage door Accessory
 @param log The logger to use
 @param config The config received from HomeBridge
 @constructor
The main class acting as the garage door Accessory @param log The logger to use @param config The config received from HomeBridge @constructor
// the service // debug flag // polling settings // cached values // process the mappers // url info //, //readObstructionState: { //	url: config.urls.readObstructionState.url, //	body: config.urls.readObstructionState.body || "" //} // initialize