iobroker.netatmo
Advanced tools
Comparing version 1.6.0 to 1.7.0
{ | ||
"common": { | ||
"name": "netatmo", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"title": "Netatmo", | ||
@@ -10,2 +10,14 @@ "titleLang": { | ||
"news": { | ||
"1.7.0": { | ||
"en": "IMPORTANT: js-controller 3.3.19 is needed at least!\nActivate events again (manually delete objects once if you get type errors)\nAdjust some roles and written data to prevent warnings in logs", | ||
"de": "WICHTIG: js-controller 3.3.19 wird mindestens benötigt!\nEreignisse erneut aktivieren (bei Tippfehlern Objekte einmalig manuell löschen)\nPassen Sie einige Rollen und geschriebene Daten an, um Warnungen in Protokollen zu vermeiden", | ||
"ru": "ВАЖНО: нужен js-контроллер версии не ниже 3.3.19!\nАктивируйте события снова (вручную удалите объекты один раз, если вы получаете ошибки типа)\nНастройте некоторые роли и записанные данные, чтобы предотвратить появление предупреждений в журналах.", | ||
"pt": "IMPORTANTE: o js-controller 3.3.19 é necessário pelo menos!\nAtive os eventos novamente (exclua manualmente os objetos uma vez se você receber erros de tipo)\nAjuste algumas funções e dados escritos para evitar avisos em logs", | ||
"nl": "BELANGRIJK: js-controller 3.3.19 is minimaal nodig!\nActiveer gebeurtenissen opnieuw (verwijder objecten één keer handmatig als u typefouten krijgt)\nPas enkele rollen en geschreven gegevens aan om waarschuwingen in logs te voorkomen", | ||
"fr": "IMPORTANT : il faut au moins js-controller 3.3.19 !\nActivez à nouveau les événements (supprimez manuellement les objets une fois si vous obtenez des erreurs de type)\nAjuster certains rôles et données écrites pour éviter les avertissements dans les journaux", | ||
"it": "IMPORTANTE: è necessario almeno js-controller 3.3.19!\nAttiva nuovamente gli eventi (elimina manualmente gli oggetti una volta se ricevi errori di digitazione)\nModifica alcuni ruoli e dati scritti per evitare avvisi nei log", | ||
"es": "IMPORTANTE: ¡se necesita js-controller 3.3.19 al menos!\nVuelva a activar los eventos (elimine manualmente los objetos una vez si obtiene errores de tipo)\nAjuste algunos roles y datos escritos para evitar advertencias en los registros", | ||
"pl": "WAŻNE: potrzebny jest przynajmniej js-controller 3.3.19!\nAktywuj zdarzenia ponownie (ręcznie usuń obiekty raz, jeśli pojawią się błędy typu)\nDostosuj niektóre role i zapisane dane, aby zapobiec ostrzeżeniom w dziennikach", | ||
"zh-cn": "重要提示:至少需要 js-controller 3.3.19!\n再次激活事件(如果遇到类型错误,请手动删除一次对象)\n调整部分角色和写入数据,防止日志出现警告" | ||
}, | ||
"1.6.0": { | ||
@@ -82,14 +94,2 @@ "en": "Important: In person names (Welcome) in state IDs forbidden characters are now replaces by _!!\nFix another potential crash case reported by sentry", | ||
"zh-cn": "删除了关于状态类型的警告" | ||
}, | ||
"1.4.1": { | ||
"en": "Removed warnings about the type of states", | ||
"de": "Warnungen über die Art der Zustände entfernt", | ||
"ru": "Убраны предупреждения о типе состояний", | ||
"pt": "Remoção de avisos sobre o tipo de estado", | ||
"nl": "Waarschuwingen over het type toestanden verwijderd", | ||
"fr": "Suppression des avertissements sur le type d'états", | ||
"it": "Rimossi gli avvisi sul tipo di stati", | ||
"es": "Se eliminaron las advertencias sobre el tipo de estados.", | ||
"pl": "Usunięto ostrzeżenia o rodzaju stanów", | ||
"zh-cn": "删除了关于状态类型的警告" | ||
} | ||
@@ -134,3 +134,3 @@ }, | ||
{ | ||
"js-controller": ">=2.0.0" | ||
"js-controller": ">=3.3.19" | ||
} | ||
@@ -137,0 +137,0 @@ ], |
@@ -1,44 +0,47 @@ | ||
const EventEmitter = require('events') | ||
const inherits = require('util').inherits; | ||
const EventEmitter = require('events'); | ||
let socket = null; | ||
let socket = null; // We use the same socket instance | ||
const socketServerUrl = 'https://iobroker.herokuapp.com/netatmo/'; | ||
function eventEmitterBridge() { | ||
EventEmitter.call(this); | ||
} | ||
class EventEmitterBridge extends EventEmitter { | ||
constructor(api, adapter) { | ||
super(); | ||
this.adapter = adapter; | ||
if (!socket) { | ||
console.log('connecting to socket') | ||
socket = require('socket.io-client')(socketServerUrl, { | ||
secure: true, | ||
reconnection: true, | ||
rejectUnauthorized: false, | ||
transports: ["websocket"] | ||
}); | ||
inherits(eventEmitterBridge, EventEmitter); | ||
socket.on("connect", () => this.adapter.log.info('Websocket connected for events')); | ||
socket.on("disconnect", (reason) => this.adapter.log.info(`Websocket disconnected for events : ${reason}`)); | ||
socket.on("connect_error", (err) => this.adapter.log.info(`Websocket error : ${err.message} : ${err.stack}`)); | ||
} | ||
eventEmitterBridge.prototype.init = function() { | ||
if (!socket) { | ||
console.log('connecting to socket') | ||
socket = require('socket.io-client')(socketServerUrl); | ||
if (socket) { | ||
socket.on('alert', data => { | ||
this.adapter.log.debug(`Websocket incoming alert: ${JSON.stringify(data)}`) | ||
this.emit('alert', data) | ||
}); | ||
api.addWebHook(socketServerUrl); | ||
} | ||
} | ||
const _this = this; | ||
if (socket) { | ||
socket.on('alert', data => onSocketAlert(_this,data)); | ||
destructor() { | ||
if (socket) { | ||
socket.disconnect(); | ||
socket = null; | ||
} | ||
} | ||
} | ||
function onSocketAlert(_this,data) { | ||
_this.emit('alert', data) | ||
} | ||
eventEmitterBridge.prototype.destructor = function() { | ||
if (socket) { | ||
socket.disconnect(); | ||
socket = null; | ||
joinHome(id) { | ||
if (socket) { | ||
socket.emit('registerHome', id); | ||
} | ||
} | ||
} | ||
eventEmitterBridge.prototype.joinHome = function(id) { | ||
if (socket) { | ||
socket.emit('registerHome', id); | ||
} | ||
} | ||
module.exports = eventEmitterBridge; | ||
module.exports = EventEmitterBridge; |
@@ -13,7 +13,5 @@ module.exports = function (myapi, myadapter) { | ||
const eventEmitterBridge = require('./eventEmitterBridge.js') | ||
const EventEmitterBridge = require('./eventEmitterBridge.js') | ||
let eeB = null; | ||
const socketServerUrl = 'https://iobroker.herokuapp.com/netatmo/'; | ||
const CODetectorEvents = ["co_detected"] | ||
@@ -29,10 +27,5 @@ const CODetectorSubtypes = { | ||
eeB = new eventEmitterBridge() | ||
if (eeB) { | ||
adapter.log.info(`Registering realtime events with ${socketServerUrl}`); | ||
eeB.init(); | ||
eeB.on('alert', async data => await onSocketAlert(data)); | ||
api.addWebHook(socketServerUrl); | ||
} | ||
eeB = new EventEmitterBridge(api, adapter) | ||
adapter.log.info(`Registering realtime events with Socket instance`); | ||
eeB.on('alert', async data => await onSocketAlert(data)); | ||
}; | ||
@@ -39,0 +32,0 @@ |
@@ -14,18 +14,11 @@ module.exports = function (myapi, myadapter) { | ||
const eventEmitterBridge = require('./eventEmitterBridge.js') | ||
const EventEmitterBridge = require('./eventEmitterBridge.js') | ||
let eeB = null; | ||
const socketServerUrl = 'https://iobroker.herokuapp.com/netatmo/'; | ||
this.init = function () { | ||
that = this; | ||
eeB = new eventEmitterBridge() | ||
if (eeB) { | ||
adapter.log.info(`Registering realtime events with ${socketServerUrl}`); | ||
eeB.init(); | ||
eeB.on('alert', async data => await onSocketAlert(data)); | ||
api.addWebHook(socketServerUrl); | ||
} | ||
eeB = new EventEmitterBridge(api, adapter) | ||
adapter.log.info(`Registering realtime events with Socket instance`); | ||
eeB.on('alert', async data => await onSocketAlert(data)); | ||
}; | ||
@@ -32,0 +25,0 @@ |
@@ -10,3 +10,3 @@ module.exports = function (myapi, myadapter) { | ||
adapter.log.debug('Received data: ' + JSON.stringify(data)); | ||
if (err === null) { | ||
if (!err) { | ||
if (Array.isArray(data)) { | ||
@@ -13,0 +13,0 @@ for (const aDevice of data) { |
@@ -15,17 +15,11 @@ module.exports = function (myapi, myadapter) { | ||
let that = null; | ||
const eventEmitterBridge = require('./eventEmitterBridge.js') | ||
const EventEmitterBridge = require('./eventEmitterBridge.js') | ||
let eeB = null; | ||
const socketServerUrl = 'https://iobroker.herokuapp.com/netatmo/'; | ||
this.init = function () { | ||
that = this; | ||
eeB = new eventEmitterBridge() | ||
if (eeB) { | ||
adapter.log.info(`Registering realtime events with ${socketServerUrl}`); | ||
eeB.init(); | ||
eeB.on('alert', async data => await onSocketAlert(data)); | ||
api.addWebHook(socketServerUrl); | ||
} | ||
eeB = new EventEmitterBridge(api, adapter) | ||
adapter.log.info(`Registering realtime events with Socket instance`); | ||
eeB.on('alert', async data => await onSocketAlert(data)); | ||
}; | ||
@@ -521,8 +515,6 @@ | ||
// Disabled due to no usage ... | ||
/* | ||
if (aHome.events) { | ||
const latestEventDate = 0; | ||
const latestEvent = null; | ||
let latestEventDate = 0; | ||
let latestEvent = null; | ||
@@ -532,2 +524,3 @@ aHome.events.forEach(function (aEvent) { | ||
adapter.log.debug(`Handle Event: ${JSON.stringify(aEvent)}`); | ||
handleEvent(aEvent, homeName, aHome.cameras); | ||
@@ -544,3 +537,2 @@ if (eventDate > latestEventDate) { | ||
} | ||
*/ | ||
} | ||
@@ -830,2 +822,3 @@ | ||
type: 'number', | ||
role: 'date', | ||
read: true, | ||
@@ -837,3 +830,3 @@ write: false | ||
await adapter.setStateAsync(fullPath + '.last_seen', { | ||
val: (new Date(aPerson.last_seen * 1000)), | ||
val: aPerson.last_seen * 1000, | ||
ack: true | ||
@@ -998,3 +991,4 @@ }); | ||
name: 'Time', | ||
type: 'date', | ||
type: 'number', | ||
role: 'date', | ||
read: true, | ||
@@ -1005,3 +999,3 @@ write: false | ||
await adapter.setStateAsync(fullPath + '.time', { | ||
val: (new Date(aEvent.time * 1000)), | ||
val: aEvent.time * 1000, | ||
ack: true | ||
@@ -1106,3 +1100,3 @@ }); | ||
name: 'Is Arrival', | ||
type: 'string', | ||
type: 'boolean', | ||
read: true, | ||
@@ -1187,3 +1181,4 @@ write: false | ||
name: 'Time', | ||
type: 'date', | ||
type: 'number', | ||
role: 'date', | ||
read: true, | ||
@@ -1193,3 +1188,3 @@ write: false | ||
}); | ||
await adapter.setStateAsync(fullPath + '.Presence.event-' + counter + '.time', { val: (new Date(aEvent.time * 1000)), ack: true }); | ||
await adapter.setStateAsync(fullPath + '.Presence.event-' + counter + '.time', { val: aEvent.time * 1000, ack: true }); | ||
@@ -1289,3 +1284,3 @@ // val: (new Date(aEvent.time * 1000)), | ||
name: 'Version', | ||
type: 'string', | ||
type: 'number', | ||
read: true, | ||
@@ -1353,3 +1348,3 @@ write: false | ||
name: 'Version', | ||
type: 'string', | ||
type: 'number', | ||
read: true, | ||
@@ -1372,32 +1367,21 @@ write: false | ||
//adapter.getForeignObject(aEventId + '.time', 'state', function (errTime, objTime) { | ||
adapter.getForeignStates(aEventId + '.time', async (errTime, objTime) => { | ||
adapter.getState(aEventId + '.time', async (errTime, stateTime) => { | ||
if (errTime) { | ||
adapter.log.error(errTime); | ||
} else if (objTime) { | ||
for (const aTimeId in objTime) { | ||
let eventDate = null; | ||
} else if (stateTime) { | ||
let eventDate = null; | ||
try { | ||
eventDate = Date.parse(stateTime.val); | ||
} catch(e) { | ||
eventDate = null; | ||
} | ||
if ((cleanupDate > eventDate) || eventDate == null) { | ||
adapter.log.info(`Event ${aEventId} expired, so cleanup`); | ||
try { | ||
eventDate = Date.parse(objTime[aTimeId].val); | ||
} catch(e) { | ||
eventDate = null; | ||
await adapter.delObjectAsync(aEventId, {recursive: true}); | ||
} catch (err) { | ||
adapter.log.warn(`Could not delete object ${aEventId} during cleanup. Please remove yourself.`); | ||
} | ||
if ((cleanupDate > eventDate) || eventDate == null) { | ||
const parentId = aTimeId.substring(0, aTimeId.length - 5); | ||
adapter.getForeignObjects(parentId + '.*', 'state', async (errState, objState) => { | ||
if (errState) { | ||
adapter.log.error(errState); | ||
} else { | ||
for (const aStateId in objState) { | ||
adapter.log.debug(`State ${aStateId} abgelaufen daher löschen!`); | ||
await adapter.delObjectAsync(aStateId); | ||
} | ||
} | ||
}); | ||
adapter.log.info(`Event ${parentId} abgelaufen daher löschen!`); | ||
await adapter.delObjectAsync(parentId); | ||
} | ||
} | ||
@@ -1404,0 +1388,0 @@ } |
{ | ||
"name": "iobroker.netatmo", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "ioBroker netatmo Adapter", | ||
@@ -39,3 +39,3 @@ "author": "Patrick Arns <iobroker@patrick-arns.de>", | ||
"request": "^2.88.2", | ||
"socket.io-client": "^4.4.1" | ||
"socket.io-client": "^1.7.4" | ||
}, | ||
@@ -42,0 +42,0 @@ "main": "main.js", |
@@ -48,2 +48,7 @@ ![Logo](admin/netatmo.png) | ||
## Changelog | ||
### 1.7.0 (2022-03-24) | ||
* IMPORTANT: js-controller 3.3.19 is needed at least! | ||
* (Apollon77) Activate events again (manually delete objects once if you get type errors) | ||
* (Apollon77) Adjust some roles and written data to prevent warnings in logs | ||
### 1.6.0 (2022-03-13) | ||
@@ -50,0 +55,0 @@ * (Apollon77) Important: In person names (Welcome) in state IDs forbidden characters are now replaces by _!! |
251321
194
5012
+ Addedafter@0.8.2(transitive)
+ Addedarraybuffer.slice@0.0.6(transitive)
+ Addedbacko2@1.0.2(transitive)
+ Addedbase64-arraybuffer@0.1.5(transitive)
+ Addedbetter-assert@1.0.2(transitive)
+ Addedblob@0.0.4(transitive)
+ Addedcallsite@1.0.0(transitive)
+ Addedcomponent-bind@1.0.0(transitive)
+ Addedcomponent-emitter@1.1.21.2.1(transitive)
+ Addedcomponent-inherit@0.0.3(transitive)
+ Addeddebug@2.2.02.3.3(transitive)
+ Addedengine.io-client@1.8.6(transitive)
+ Addedengine.io-parser@1.3.2(transitive)
+ Addedhas-binary@0.1.7(transitive)
+ Addedhas-cors@1.1.0(transitive)
+ Addedindexof@0.0.1(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedjson3@3.3.2(transitive)
+ Addedms@0.7.10.7.2(transitive)
+ Addedobject-component@0.0.3(transitive)
+ Addedoptions@0.0.6(transitive)
+ Addedparsejson@0.0.3(transitive)
+ Addedparseqs@0.0.5(transitive)
+ Addedparseuri@0.0.5(transitive)
+ Addedsocket.io-client@1.7.4(transitive)
+ Addedsocket.io-parser@2.3.1(transitive)
+ Addedto-array@0.1.4(transitive)
+ Addedultron@1.0.2(transitive)
+ Addedws@1.1.5(transitive)
+ Addedwtf-8@1.0.0(transitive)
+ Addedxmlhttprequest-ssl@1.6.3(transitive)
+ Addedyeast@0.1.2(transitive)
- Removed@socket.io/component-emitter@3.1.2(transitive)
- Removeddebug@4.3.7(transitive)
- Removedengine.io-client@6.6.2(transitive)
- Removedengine.io-parser@5.2.3(transitive)
- Removedms@2.1.3(transitive)
- Removedsocket.io-client@4.8.1(transitive)
- Removedsocket.io-parser@4.2.4(transitive)
- Removedws@8.17.1(transitive)
- Removedxmlhttprequest-ssl@2.1.2(transitive)
Updatedsocket.io-client@^1.7.4