iobroker.netatmo
Advanced tools
Comparing version 0.6.0 to 0.6.1
{ | ||
"common": { | ||
"name": "netatmo", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"title": "Netatmo Adapter", | ||
@@ -22,4 +22,3 @@ "desc": { | ||
"loglevel": "info", | ||
"type": "hardware", | ||
"localLink": "http://%ip%:%port%" | ||
"type": "hardware" | ||
}, | ||
@@ -26,0 +25,0 @@ "native": { |
@@ -15,3 +15,3 @@ module.exports = function (myapi, myadapter) { | ||
var socketServerUrl = 'https://netatmo-connect.herokuapp.com/'; | ||
var socketServerUrl = 'https://iobroker.herokuapp.com/netatmo/'; | ||
@@ -25,3 +25,3 @@ this.init = function () { | ||
socket.on('alert', onSocketAlert); | ||
api.addWebHook(socketServerUrl + "netatmo-webhook/"); | ||
api.addWebHook(socketServerUrl); | ||
} | ||
@@ -71,5 +71,25 @@ }; | ||
function onSocketAlert(data) { | ||
if (data && data.persons) { | ||
adapter.log.info("Got an realtime event, requesting update!"); | ||
that.requestUpdateIndoorCamera(); | ||
adapter.log.info("received a realtime event ..."); | ||
var now = (new Date()).toISOString(); | ||
if (data) { | ||
var path = data.home_name + ".LastEventData."; | ||
if (data.event_type === "person") { | ||
data.persons.forEach(function (person) { | ||
var dataPath = ""; | ||
if (person.is_known) | ||
dataPath = "LastKnownPersonSeen"; | ||
else | ||
dataPath = "LastUnknownPersonSeen"; | ||
adapter.setState(path + dataPath, {val: now, ack: true}); | ||
}); | ||
that.requestUpdateIndoorCamera(); | ||
} else if (data.event_type === "movement") { | ||
adapter.setState(path + "LastMovementDetected", {val: now, ack: true}); | ||
} | ||
} | ||
@@ -88,7 +108,8 @@ } | ||
// Join HomeID | ||
if (socket) | ||
if (socket) { | ||
socket.emit("registerHome", aHome.id); | ||
} | ||
adapter.setObjectNotExists(homeName, { | ||
type: "enum", | ||
type: "channel", | ||
common: { | ||
@@ -105,19 +126,53 @@ name: homeName, | ||
if (aHome.id) { | ||
adapter.setObjectNotExists(fullPath + ".id", { | ||
type: "state", | ||
common: { | ||
name: "HomeID", | ||
type: "string", | ||
read: true, | ||
write: false | ||
} | ||
}); | ||
adapter.setState(fullPath + ".id", {val: aHome.id, ack: true}); | ||
} | ||
adapter.setObjectNotExists(homeName + ".LastEventData.LastMovementDetected", { | ||
type: "state", | ||
common: { | ||
name: "LastMovementDetected", | ||
type: "string", | ||
read: true, | ||
write: false | ||
}, | ||
native: { | ||
id: aHome.id | ||
} | ||
}); | ||
adapter.setObjectNotExists(homeName + ".LastEventData.LastKnownPersonSeen", { | ||
type: "state", | ||
common: { | ||
name: "LastKnownPersonSeen", | ||
type: "string", | ||
read: true, | ||
write: false | ||
}, | ||
native: { | ||
id: aHome.id | ||
} | ||
}); | ||
adapter.setObjectNotExists(homeName + ".LastEventData.LastUnknownPersonSeen", { | ||
type: "state", | ||
common: { | ||
name: "LastUnknownPersonSeen", | ||
type: "string", | ||
read: true, | ||
write: false | ||
}, | ||
native: { | ||
id: aHome.id | ||
} | ||
}); | ||
adapter.setObjectNotExists(homeName + ".LastEventData", { | ||
type: "channel", | ||
common: { | ||
name: "LastEventData", | ||
type: "string", | ||
read: true, | ||
write: false | ||
} | ||
}); | ||
if (aHome.cameras) { | ||
aHome.cameras.forEach(function (aCamera) { | ||
if (aCamera.id && aCamera.name) { | ||
@@ -184,15 +239,2 @@ adapter.setObjectNotExists(fullPath + "." + aCamera.name, { | ||
adapter.setObjectNotExists(infoPath, { | ||
type: "channel", | ||
common: { | ||
name: aCamera.name, | ||
type: "channel", | ||
read: true, | ||
write: false | ||
}, | ||
native: { | ||
id: aCamera.id | ||
} | ||
}); | ||
if (aCamera.id) { | ||
@@ -366,3 +408,3 @@ adapter.setObjectNotExists(infoPath + ".id", { | ||
adapter.setObjectNotExists(fullPath, { | ||
type: "enum", | ||
type: "channel", | ||
common: { | ||
@@ -386,3 +428,3 @@ name: "Persons", | ||
adapter.setObjectNotExists(fullPath, { | ||
type: "enum", | ||
type: "channel", | ||
common: { | ||
@@ -570,3 +612,3 @@ name: fullPath, | ||
adapter.setObjectNotExists(fullPath, { | ||
type: "enum", | ||
type: "channel", | ||
common: { | ||
@@ -573,0 +615,0 @@ name: "Events", |
{ | ||
"name": "iobroker.netatmo", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "ioBroker netatmo Adapter", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -16,2 +16,7 @@ ![Logo](admin/netatmo.png) | ||
### 0.6.1 | ||
* (PArns) Changed realtime server to use new general realtime server | ||
* (PArns) Changed enums to channels to avoid enum creation | ||
* (PArns) Simplified detection for movement-, known- & unknown- face events | ||
### 0.6.0 | ||
@@ -18,0 +23,0 @@ * (PArns) Rewritten realtime updates to not need a local server any longer! Realtime updates are now turned on by default if a Welcome or Present cam is available |
109722
1825
76