Compare commits

...

1 Commits

Author SHA1 Message Date
Simon Zeyer
388bcc6c2c handle exception and restart pullingafter timeout 2024-09-26 14:14:23 +02:00
2 changed files with 44 additions and 31 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "Divera Status", "name": "Divera Status",
"version": "0.0.1", "version": "0.0.2",
"description": "Übernehmen des Status aus der Divera App in Alarmiator", "description": "Übernehmen des Status aus der Divera App in Alarmiator",
"main": "base.js", "main": "base.js",
"service": "service.js", "service": "service.js",

View File

@ -238,7 +238,15 @@ async function onStateChange(consumer_id, status_id){
} }
} }
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
async function startAPI() { async function startAPI() {
while(true){
try{
let _auth = await auth() let _auth = await auth()
if(_auth){ if(_auth){
global.logger.info('auth OK') global.logger.info('auth OK')
@ -274,5 +282,10 @@ async function startAPI() {
} }
} }
} }
}catch(err){
console.error(err);
}
await sleep(10000);
global.logger.info('auth mit API_KEY war nicht erfolgreich. Service ist gestoppt und startet nicht mehr automatisch??') global.logger.info('auth mit API_KEY war nicht erfolgreich. Service ist gestoppt und startet nicht mehr automatisch??')
}
} }