Skip to content

Commit

Permalink
chore: release v3.0.11
Browse files Browse the repository at this point in the history
we now handle some more edge case errors
  • Loading branch information
foxriver76 committed Jan 29, 2021
1 parent 646510f commit b43ecd5
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 39 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ with the ioBroker CLI. You can change the port via `iob set hm-rega.<instance> -
### __WORK IN PROGRESS__
-->

### 3.0.11 (2021-01-29)
* (foxriver76) we now handle some more edge case errors

### 3.0.10 (2021-01-27)
* (foxriver76) no build needed

Expand Down
82 changes: 59 additions & 23 deletions hm-rega.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function startAdapter(options) {

name: adapterName,

stateChange: (id, state) => {
stateChange: async (id, state) => {
if (!state || state.ack) {
if (state && id === pollingTrigger) {
adapter.log.info('pollingTrigger');
Expand All @@ -66,8 +66,12 @@ function startAdapter(options) {
// Read devices anew if hm-rpc updated the list of devices
if (state.val) {
setTimeout(() => getDevices(), 1000);
// Reset flag
adapter.setForeignState(id, false, true);
try {
// Reset flag
await adapter.setForeignStateAsync(id, false, true);
} catch {
// ignore
}
}
} else if (id === `${adapter.config.rfdAdapter}.info.connection` ||
id === `${adapter.config.virtualDevicesAdapter}.info.connection` ||
Expand Down Expand Up @@ -320,31 +324,47 @@ function main() {
adapter.log.error(`ReGaHSS ${adapter.config.homematicAddress} down`);
ccuReachable = true;
ccuRegaUp = false;
adapter.setState('info.connection', false, true);
adapter.setState('info.ccuReachable', ccuReachable, true);
adapter.setState('info.ccuRegaUp', ccuRegaUp, true);
try {
await adapter.setStateAsync('info.connection', false, true);
await adapter.setStateAsync('info.ccuReachable', ccuReachable, true);
await adapter.setStateAsync('info.ccuRegaUp', ccuRegaUp, true);
} catch {
// ignore
}

} else if (err === 'CCU unreachable') {
adapter.log.error(`CCU ${adapter.config.homematicAddress} unreachable`);
ccuReachable = false;
ccuRegaUp = false;
adapter.setState('info.connection', false, true);
adapter.setState('info.ccuReachable', ccuReachable, true);
adapter.setState('info.ccuRegaUp', ccuRegaUp, true);
try {
await adapter.setStateAsync('info.connection', false, true);
await adapter.setStateAsync('info.ccuReachable', ccuReachable, true);
await adapter.setStateAsync('info.ccuRegaUp', ccuRegaUp, true);
} catch {
// ignore
}
} else if (err) {
adapter.log.error(err);
ccuReachable = false;
ccuRegaUp = false;
adapter.setState('info.connection', false, true);
adapter.setState('info.ccuReachable', ccuReachable, true);
adapter.setState('info.ccuRegaUp', ccuRegaUp, true);
try {
await adapter.setStateAsync('info.connection', false, true);
await adapter.setStateAsync('info.ccuReachable', ccuReachable, true);
await adapter.setStateAsync('info.ccuRegaUp', ccuRegaUp, true);
} catch {
// ignore
}
} else {
adapter.log.info(`ReGaHSS ${adapter.config.homematicAddress} up`);
ccuReachable = true;
ccuRegaUp = true;
adapter.setState('info.connection', true, true);
adapter.setState('info.ccuReachable', ccuReachable, true);
adapter.setState('info.ccuRegaUp', ccuRegaUp, true);
try {
await adapter.setStateAsync('info.connection', true, true);
await adapter.setStateAsync('info.ccuReachable', ccuReachable, true);
await adapter.setStateAsync('info.ccuRegaUp', ccuRegaUp, true);
} catch {
// ignore
}

await rega.checkTime();

Expand Down Expand Up @@ -427,7 +447,11 @@ async function pollVariables() {

if (!states[fullId] || !states[fullId].ack || states[fullId].val !== val || (states[fullId].ts && states[fullId].ts !== timestamp)) {
states[fullId] = {val: val, ack: true, ts: timestamp};
adapter.setForeignState(fullId, val, true);
try {
await adapter.setForeignStateAsync(fullId, val, true);
} catch {
// ignore
}
}
}
}
Expand Down Expand Up @@ -578,7 +602,11 @@ async function pollPrograms() {
states[fullId].val !== val
) {
states[fullId] = {val: val, ack: true};
adapter.setForeignState(fullId, states[fullId]);
try {
await adapter.setForeignStateAsync(fullId, states[fullId]);
} catch {
// ignore
}
}
}
}
Expand Down Expand Up @@ -632,7 +660,11 @@ async function pollServiceMsgs() {
states[id].ts !== state.ts
) {
states[id] = state;
adapter.setForeignState(id, state);
try {
await adapter.setForeignStateAsync(id, state);
} catch {
// ignore
}
}
}
}
Expand Down Expand Up @@ -1340,7 +1372,7 @@ async function getDatapoints() {
id += `${tmp[1].replace(':', '.').replace(FORBIDDEN_CHARS, '_')}.${tmp[2].replace(FORBIDDEN_CHARS, '_')}`;

// convert dimmer and blinds
if (typeof units[id] === 'object') {
if (units[id] && typeof units[id] === 'object') {
// data[dp] = ((parseFloat(data[dp]) - units[id].MIN) / (units[id].MAX - units[id].MIN)) * 100;
const max = units[id].MAX;
// check if we need to scale
Expand Down Expand Up @@ -2094,10 +2126,14 @@ function convertDataToJSON(data) {

let stopCount = 0;

function stop(callback) {
adapter.setState('info.connection', false, true);
adapter.setState('info.ccuReachable', false, true);
adapter.setState('info.ccuRegaUp', false, true);
async function stop(callback) {
try {
await adapter.setStateAsync('info.connection', false, true);
await adapter.setStateAsync('info.ccuReachable', false, true);
await adapter.setStateAsync('info.ccuRegaUp', false, true);
} catch {
// ignore
}

if (!stopCount) {
clearInterval(pollingInterval);
Expand Down
28 changes: 14 additions & 14 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@
"$schema": "https://raw.githubusercontent.com/foxriver76/ioBroker.js-controller/schemas/schemas/io-package.json",
"common": {
"name": "hm-rega",
"version": "3.0.10",
"version": "3.0.11",
"news": {
"3.0.11": {
"en": "we now handle some more edge case errors",
"de": "Wir behandeln jetzt einige weitere Randfallfehler",
"ru": "Теперь мы обрабатываем еще несколько ошибок крайнего случая",
"pt": "agora lidamos com mais alguns erros de caso extremo",
"nl": "we behandelen nu wat meer edge case-fouten",
"fr": "nous traitons maintenant d'autres erreurs de cas de bord",
"it": "ora gestiamo altri errori di casi limite",
"es": "ahora manejamos algunos errores más de casos extremos",
"pl": "teraz zajmiemy się więcej błędami w przypadku skrajnych przypadków",
"zh-cn": "我们现在处理更多边缘情况错误"
},
"3.0.10": {
"en": "no build needed",
"de": "Kein Build erforderlich",
Expand Down Expand Up @@ -231,18 +243,6 @@
"es": "Se corrigió el bloqueo cuando no podemos determinar la versión de CCU",
"pl": "naprawiono awarię, gdy nie możemy ustalić wersji CCU",
"zh-cn": "修复了无法确定CCU版本时的崩溃"
},
"2.6.8": {
"en": "Script post requests will time out after 15 seconds to prevent stucking in queue if no answer from ccu received",
"de": "Skript-Post-Anfragen laufen nach 15 Sekunden ab, um zu verhindern, dass sie in der Warteschlange hängen bleiben, wenn keine Antwort von ccu empfangen wird",
"ru": "Сценарий отправки запросов истекает через 15 секунд, чтобы предотвратить зависание в очереди, если не получен ответ от ccu",
"pt": "As solicitações de postagem de script atingem o tempo limite após 15 segundos para evitar a espera na fila se nenhuma resposta da ccu for recebida",
"nl": "Verzoeken voor scriptposts verlopen na 15 seconden om te voorkomen dat ze in de wachtrij blijven steken als er geen antwoord van ccu wordt ontvangen",
"fr": "Les demandes de publication de script expireront au bout de 15 secondes pour empêcher le blocage dans la file d'attente si aucune réponse du ccu n'est reçue",
"it": "Le richieste di post degli script scadranno dopo 15 secondi per impedire il blocco in coda se non viene ricevuta alcuna risposta da ccu",
"es": "Las solicitudes de publicación de guiones se agotarán después de 15 segundos para evitar el bloqueo en la cola si no se recibe respuesta de ccu",
"pl": "Żądania wysłania skryptu przekroczą limit czasu po 15 sekundach, aby zapobiec utknięciu w kolejce, jeśli nie otrzymano odpowiedzi od ccu",
"zh-cn": "如果未收到ccu的答复,则脚本发布请求将在15秒后超时,以防止卡在队列中"
}
},
"title": "HomeMatic ReGaHSS",
Expand Down Expand Up @@ -402,4 +402,4 @@
"native": {}
}
]
}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.hm-rega",
"version": "3.0.10",
"version": "3.0.11",
"engines": {
"node": ">=10.0.0"
},
Expand Down

0 comments on commit b43ecd5

Please sign in to comment.