Skip to content

Commit

Permalink
Release 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jghaanstra committed May 24, 2019
1 parent c05008c commit e646fbf
Show file tree
Hide file tree
Showing 25 changed files with 1,396 additions and 711 deletions.
6 changes: 3 additions & 3 deletions APPSTORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ For support please use the official support topic on the forum [here](https://co
- When using multiple IP Webcameras only one global image token is registered and available. This is due to current limitations of Homey core and will hopefully become available in the future.

## Changelog
### v1.2.8 - 2019-03-04
* FIX: improvements to pairing and settings template for firmware 2.x
* FIX: code improvements to avoid continous spinner on email snapshot action card
### v1.3.0 - 2019-05-24
BREAKING CHANGES: this update will break the snapshot tokens, both the global and the trigger card tokens. The snapshot tokens have been updated to an officially supported image token that has been made available with firmware 2.2.0 and smartphone app version 2.4.0. You will have to update your flows where these snapshot tokens are in use.
* IMPROVEMENT: support for the new devices / driver images
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class IpwebcamApp extends Homey.App {
new Homey.FlowCardAction('emailsnapshot')
.register()
.registerRunListener(async (args) => {
const image = await util.createSnapshot(args.device.getSetting('address'), args.device.getSetting('port'), args.device.getSetting('username'), args.device.getSetting('password'))
const image = await util.getBufferSnapshot('http://'+ args.device.getSetting('address') +':'+ args.device.getSetting('port') +'/shot.jpg', args.device.getSetting('username'), args.device.getSetting('password'))
if (image) {
return util.sendSnapshot(image, args);
} else {
Expand Down
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"en": [ "ip webcam", "android" ],
"nl": [ "ip webcam", "android" ]
},
"version": "1.2.8",
"compatibility": ">=2.0.0",
"version": "1.3.0",
"compatibility": ">=2.2.0",
"author": {
"name": "Jelger Haanstra",
"email": "[email protected]",
Expand Down
33 changes: 8 additions & 25 deletions drivers/ipwebcam/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,18 @@ class IpwebcamDevice extends Homey.Device {
this.pollDevice(interval);

// LIVE SNAPSHOT TOKEN
let ipwebcamSnapshot = new Homey.Image('jpg');
ipwebcamSnapshot.setBuffer(async () => {
try {
const image = await util.createSnapshot(this.getSetting('address'), this.getSetting('port'), this.getSetting('username'), this.getSetting('password'))
if (image) {
return image;
} else {
throw new Error('Invalid Response');
}
} catch(error) {
this.error(error);
this.ipwebcamSnapshot = new Homey.Image();
this.ipwebcamSnapshot.setStream(async (stream) => {
const res = await util.getStreamSnapshot('http://'+ this.getSetting('address') +':'+ this.getSetting('port') +'/shot.jpg', this.getSetting('username'), this.getSetting('password'));
if(!res.ok)
throw new Error('Invalid Response');
}

return res.body.pipe(stream);
});

ipwebcamSnapshot.register()
this.ipwebcamSnapshot.register()
.then(() => {
let ipwebcamSnapshotToken = new Homey.FlowToken('ipwebcam_snapshot', {
type: 'image',
title: Homey.__('Live Snapshot')
})

ipwebcamSnapshotToken
.register()
.then(() => {
ipwebcamSnapshotToken.setValue(ipwebcamSnapshot);
})
.catch(this.error.bind(this, 'ipwebcamSnapshotToken.register'));

return this.setCameraImage('ipwebcam', Homey.__('Live Snapshot'), this.ipwebcamSnapshot);
})
.catch(this.error.bind(this, 'ipwebcamSnapshot.register'));
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/ipwebcam/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class IpwebcamDriver extends Homey.Driver {

onPair(socket) {
socket.on('testConnection', function(data, callback) {
util.createSnapshot(data.address, data.port, data.username, data.password)
util.getBufferSnapshot('http://'+ data.address +':'+ data.port +'/shot.jpg', data.username, data.password)
.then(image => {
callback(false, image.toString('base64'));
})
Expand Down
21 changes: 19 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ exports.getHomeyIp = function () {
})
}

exports.createSnapshot = function (address, port, username, password) {
exports.getBufferSnapshot = function (url, username, password) {
return new Promise(function (resolve, reject) {
fetch('http://'+ address +':'+ port +'/shot.jpg', {
fetch(url, {
method: 'GET',
headers: {'Authorization': 'Basic ' + Buffer.from(username + ":" + password).toString('base64')},
timeout: 10000
Expand All @@ -32,6 +32,23 @@ exports.createSnapshot = function (address, port, username, password) {
})
}

exports.getStreamSnapshot = function (url, username, password) {
return new Promise(function (resolve, reject) {
fetch(url, {
method: 'GET',
headers: {'Authorization': 'Basic ' + Buffer.from(username + ":" + password).toString('base64')},
timeout: 10000
})
.then(checkStatus)
.then(res => {
return resolve(res);
})
.catch(err => {
return reject(err);
});
})
}

exports.getIpwebcam = function (address, port, username, password) {
return new Promise(function (resolve, reject) {
fetch('http://'+ address +':'+ port +'/sensors.json', {
Expand Down
28 changes: 14 additions & 14 deletions locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
"testing" : "IP Webcam connectietest succesvol, je kan de IP Webcam nu verbinden.",
"connect": "Verbind"
},
"settings": {
"title": "IP Webcam Instellingen",
"intro-email": "Deze instellingen zijn nodig voor het versturen van snapshots via email. Indien je via Gmail SMTP servers wil versturen en je maakt gebruik van 2-traps authenticatie moet je eerst een <a href='https://support.google.com/accounts/answer/185833' target='_blank'>app wachtwoord</a> instellen in je Google Account.",
"emailsettings": "Email instellingen",
"username": "Email gebruikersnaam",
"password": "Email wachtwoord",
"hostname": "SMTP server",
"port": "SMTP port",
"sender": "Verzender email adres",
"secure": "Beveiligde verbinding",
"testemail": "Test email instellingen",
"saveemail": "Opslaan email instellingen",
"testing": "Instellingen zijn succesvol getest. Je zou een test email moeten hebben ontvangen.",
"success": "Instellingen zijn succesvol opgeslagen."
"settings": {
"title": "IP Webcam Instellingen",
"intro-email": "Deze instellingen zijn nodig voor het versturen van snapshots via email. Indien je via Gmail SMTP servers wil versturen en je maakt gebruik van 2-traps authenticatie moet je eerst een <a href='https://support.google.com/accounts/answer/185833' target='_blank'>app wachtwoord</a> instellen in je Google Account.",
"emailsettings": "Email instellingen",
"username": "Email gebruikersnaam",
"password": "Email wachtwoord",
"hostname": "SMTP server",
"port": "SMTP port",
"sender": "Verzender email adres",
"secure": "Beveiligde verbinding",
"testemail": "Test email instellingen",
"saveemail": "Opslaan email instellingen",
"testing": "Instellingen zijn succesvol getest. Je zou een test email moeten hebben ontvangen.",
"success": "Instellingen zijn succesvol opgeslagen."
},
"Unreachable": "Onbereikbaar",
"Live Snapshot": "Live snapshot",
Expand Down
38 changes: 38 additions & 0 deletions node_modules/node-fetch/CHANGELOG.md

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

Loading

0 comments on commit e646fbf

Please sign in to comment.