Skip to content

Commit

Permalink
Merge pull request #64 from simatec/multiplatform
Browse files Browse the repository at this point in the history
(simatec) Added Pushover Notification
  • Loading branch information
simatec authored Dec 4, 2018
2 parents 4ebe736 + 6fffeb2 commit bf0632b
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 12 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Backitup is a backup solution that allows cyclical backup of an IoBroker install

## Changelog

### 0.4.0 (04.12.2018)
* (simatec) Added Pushover Notification

### 0.3.9 (03.12.2018)
* (simatec) Fix cifs/nfs mount and umount

Expand Down
31 changes: 31 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@
getAdapterInstances('email', function (instances) {
fillInstances('emailInstance', instances, settings['emailInstance']);
});

getAdapterInstances('pushover', function (instances) {
fillInstances('pushoverInstance', instances, settings['pushoverInstance']);
});

if (!settings.ccuHost) {
fetchCcuConfig(true);
Expand Down Expand Up @@ -554,10 +558,16 @@
$('#notificationsType').on('change', function () {
if ($(this).val() === 'Telegram') {
$('.email').hide();
$('.pushover').hide();
$('.telegram').show();
} else if ($(this).val() === 'E-Mail') {
$('.email').show();
$('.telegram').hide();
$('.pushover').hide();
} else if ($(this).val() === 'Pushover') {
$('.pushover').show();
$('.telegram').hide();
$('.email').hide();
}
}).trigger('change');
/*
Expand Down Expand Up @@ -891,6 +901,7 @@
<select class="value" id="notificationsType">
<option value="Telegram" class="translate">Telegram</option>
<option value="E-Mail" class="translate">E-Mail</option>
<option value="Pushover" class="translate">Pushover</option>
</select>
<label for="notificationsType" class="translate">notifications type</label>
</div>
Expand Down Expand Up @@ -919,6 +930,26 @@
<label class="translate" for="telegramNoticeType">Notification Style</label>
</div>
</div>
<!-- Pushover -->
<div class="row pushover">
<div class="input-field col s12 m6 l3 pushover">
<select id="pushoverInstance" class="value"></select>
<label for="pushoverInstance" class="translate">Pushover instance</label>
</div>
<div class="input-field col s12 m6 l3 pushover">
<select class="value" id="pushoverNoticeType">
<option value="longPushoverNotice" class="translate">Long Notifications</option>
<option value="shortPushoverNotice" class="translate">Short Notifications</option>
</select>
<label class="translate" for="pushoverNoticeType">Notification Style</label>
</div>
</div>
<div class="row pushover">
<div class="input-field col s12 m6 l3 pushover">
<input class="value" id="pushoverSilentNotice" type="checkbox"/>
<label for="pushoverSilentNotice" class="translate">Silent Notice</label>
</div>
</div>
<!-- email -->
<div class="row email">
<div class="input-field col s12 m6 l3 email">
Expand Down
22 changes: 12 additions & 10 deletions admin/words.js

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
{
"common": {
"name": "backitup",
"version": "0.3.9",
"version": "0.4.0",
"news": {
"0.4.0": {
"en": "Added Pushover Notification",
"de": "Pushover-Benachrichtigung hinzugefügt",
"ru": "Добавлено Pushover Уведомление",
"pt": "Adicionado Pushover Notification",
"nl": "Pushover-melding toegevoegd",
"fr": "Notification Pushover ajoutée",
"it": "Aggiunta notifica pushover",
"es": "Notificación Pushover añadida",
"pl": "Dodano powiadomienie pushover"
},
"0.3.9": {
"en": "Fix cifs/nfs mount and umount",
"de": "Fix cifs/nfs mount und umount",
Expand Down Expand Up @@ -423,6 +434,11 @@
"telegramInstance": "telegram.0",
"telegramNoticeType": "longTelegramNotice",
"telegramUser": "All Receiver",
"telegramSilentNotice": false,

"pushoverInstance": "pushover.0",
"pushoverNoticeType": "longPushoverNotice",
"pushoverSilentNotice": false,

"emailReceiver": "[email protected]",
"emailSender": "[email protected]",
Expand Down
8 changes: 8 additions & 0 deletions lib/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ function executeScripts(adapter, config, callback, scripts, code) {
options[name].time = tools.getTimeString(options[name].systemLang); // provide date
}
break;

case 'pushover':
if (config[name] && config[name].enabled && config[name].notificationsType === 'Pushover') {
func = scripts[name];
options = JSON.parse(JSON.stringify(config));
options[name].time = tools.getTimeString(options[name].systemLang); // provide date
}
break;
}

scripts[name] = null;
Expand Down
50 changes: 50 additions & 0 deletions lib/scripts/90-pushover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict';
const _ = require('../tools')._;

function command(options, log, callback) {
if (options.pushover.enabled &&
options.adapter &&
options.pushover.instance !== '' &&
options.pushover.instance !== null &&
options.pushover.instance !== undefined) {

// Send pushover Message
if (options.debugging) {
log.debug(`[${options.name}] used pushover-Instance: ${options.pushover.instance}`);
}

// analyse here the info from options.context.error and options.context.done
console.log(JSON.stringify(options.context.errors));
console.log(JSON.stringify(options.context.done));

let messageText = _('New %e Backup created on %t', options.pushover.systemLang);
messageText = messageText.replace('%t', options.pushover.time).replace('%e', options.name);
if (options.ftp && options.ftp.enabled && options.pushover.NoticeType == 'longPushoverNotice') {
const m = _(', and copied / moved via FTP to %h%d', options.pushover.systemLang);
messageText += m.replace('%h', options.ftp.host).replace('%d', options.ftp.dir);
}

if (options.cifs && options.cifs.enabled && options.pushover.NoticeType == 'longPushoverNotice') {
const m = _(', and stored under %h%d', options.pushover.systemLang);
messageText += m.replace('%h', options.cifs.mount).replace('%d', options.cifs.dir);
}

if (options.dropbox && options.dropbox.enabled && options.pushover.NoticeType == 'longPushoverNotice') {
messageText +=_(', and stored in dropbox', options.pushover.systemLang);
}

messageText += '.';
if(options.pushover.SilentNotice === 'true' || options.pushover.SilentNotice === true){
options.adapter.sendTo(options.pushover.instance, 'send', {message: 'BackItUp:\n' + messageText, sound: '', priority: -1, title: 'Backitup'});
}else{
options.adapter.sendTo(options.pushover.instance, 'send', {message: 'BackItUp:\n' + messageText, sound: '', title: 'Backitup'});
}
}
callback();
}

module.exports = {
command,
ignoreErrors: true,
afterBackup: true
};
13 changes: 13 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ function initConfig(secret) {
systemLang
};

const pushover = {
enabled: adapter.config.notificationEnabled,
notificationsType: adapter.config.notificationsType,
type: 'message',
instance: adapter.config.pushoverInstance,
SilentNotice: adapter.config.pushoverSilentNotice,
NoticeType: adapter.config.pushoverNoticeType,
systemLang
};

const email = {
enabled: adapter.config.notificationEnabled,
notificationsType: adapter.config.notificationsType,
Expand Down Expand Up @@ -323,6 +333,7 @@ function initConfig(secret) {
history,
telegram,
email,
pushover,
};

// Configurations for CCU / pivCCU / RaspberryMatic backup
Expand All @@ -342,6 +353,7 @@ function initConfig(secret) {
history,
telegram,
email,
pushover,

host: adapter.config.ccuHost, // IP-address CCU
user: adapter.config.ccuUser, // username CCU
Expand All @@ -365,6 +377,7 @@ function initConfig(secret) {
history,
telegram,
email,
pushover,

//mysql,
mysql: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.backitup",
"version": "0.3.9",
"version": "0.4.0",
"engines": {
"node": ">=6.0.0"
},
Expand Down

0 comments on commit bf0632b

Please sign in to comment.