casa-calida
Version:
Connects your RaZberry to the casa-calida servers. Runs directly on your Raspberry Pi.
51 lines (42 loc) • 1.27 kB
JavaScript
;
/**
* @author <a href="mailto:stefan@stefanmayer.me">Stefan Mayer</a>
*/
module.exports = {
setPath(newPath) {
this.path = newPath;
},
getConfig() {
if (!this.path) {
return {
zwave: {},
casacalida: {}
};
}
return require(this.path);
},
getZwaveBaseUrl() {
const zwaveConfig = this.getConfig().zwave;
return `${zwaveConfig.secure ? 'https' : 'http'}://${zwaveConfig.server}:${zwaveConfig.port}`;
},
getCasaCalidaBaseUrl() {
const hcConfig = this.getConfig().casacalida;
return `${hcConfig.secure ? 'https' : 'http'}://${hcConfig.server}:${hcConfig.port}/api/`;
},
getCasaClidaWebsocketBaseUrl() {
const hcConfig = this.getConfig().casacalida;
return `${hcConfig.secure ? 'wss' : 'ws'}://${hcConfig.server}${hcConfig.port ? `:${hcConfig.port}` : ''}`;
},
getToken() {
return this.getConfig().casacalida.token;
},
getAuthentication() {
return {
username: this.getConfig().zwave.username,
password: this.getConfig().zwave.password
};
},
getIotIps() {
return this.getConfig().cciot;
}
};