Skip to content

Commit

Permalink
Merge pull request #26 from Veldkornet/patch-2
Browse files Browse the repository at this point in the history
Add group notification functionality
  • Loading branch information
PandaNL committed Jun 12, 2019
2 parents d1ddc99 + ce18d6a commit 1f1777d
Show file tree
Hide file tree
Showing 7 changed files with 516 additions and 140 deletions.
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,46 @@ This app lets you send Pushover notifications to use in flows on a Homey device

1. Go to Pushover.net and login
2. Grab your user key
3. Create a new application for Homey https://pushover.net/apps/build
4. Grab your created application key
5. Go to settings on your Homey, and under Pushover Notifications fill in your user & application/token key and save.
3. Grab your relevant group key (if used)
4. Create a new application for Homey https://pushover.net/apps/build
5. Grab your created application key
6. Go to settings on your Homey, and under Pushover Notifications fill in your user, group & application/token key and save.

### Donate
## Donate
If the Pushover app is useful to you, buy me a beer!

[![Paypal donate][pp-donate-image]][pp-donate-link]

[pp-donate-link]: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=D8RA9P824YZ62&lc=NL&item_name=Pushover%2dHomey&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
[pp-donate-image]: https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif

### Changelog
## Changelog

0.0.9
### 0.0.12
* Multiple fixes (thanks to Vekdkornet):
* Updated colour scheme to "Pushover blue"
* Support for group notifications. Add your group key under settings.
* Additional Dutch translations

- Image support thanks to Kevin Traa
### 0.0.11
* Multiple fixes (thanks to Vekdkornet):
* Fixed an issue where all messages were being sent as "Normal" priority
* Fixed an issue where the send message to device flow would not work
* Added Notification Sound on the Image Flow Card
* Added support for Custom Subject
* Added support for Device Default Sound
* Added support for Emergency Priority

0.0.8
### 0.0.10
* Fixed device selection in flow card
* Added confirmation for saved settings

- Fixed bug where logging didn't work for pushover device card
### 0.0.9
* Image support thanks to Kevin Traa

0.0.7
### 0.0.8
* Fixed bug where logging didn't work for pushover device card

- Added check to see if Message isn't empty to fix app crash
- Added Insight logging support
### 0.0.7
* Added check to see if Message isn't empty to fix app crash
* Added Insight logging support
45 changes: 23 additions & 22 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ let request = [];
let validation;
let devices = null;
let pushoverUser = null;
let pushoverGroup = null;
let pushoverToken = null;
let ledringPreference = false;
let InsightLog = null;

class MyApp extends Homey.App {

onInit() {

// Start building Pushover accounts array
buildPushoverArray();

createInsightlog();

Homey.ManagerSettings.on('set', function (settingname) {

if (settingname == 'pushoveraccount') {
console.log('Pushover - Account has been changed/updated...');
buildPushoverArray();
Expand Down Expand Up @@ -61,7 +57,15 @@ class MyApp extends Homey.App {
.registerRunListener(( args, state ) => {

if (typeof validation == 'undefined' || validation == '0') return new Error("Pushover api/token key not configured or valid under settings!");
let tempUser = pushoverUser;
let tempUser = null;
switch (args.target) {
case 'User':
tempUser = pushoverUser;
break;
case 'Group':
tempUser = pushoverGroup;
break;
}
let tempToken = pushoverToken;
let pTitle = args.title;
let pMessage = args.message;
Expand All @@ -79,7 +83,15 @@ class MyApp extends Homey.App {
.registerRunListener(( args, state) => {

if (typeof validation == 'undefined' || validation == '0') return callback(new Error("Pushover api/token key not configured or valid under settings!"));
let tempUser = pushoverUser;
let tempUser = null;
switch (args.target) {
case 'User':
tempUser = pushoverUser;
break;
case 'Group':
tempUser = pushoverGroup;
break;
}
let tempToken = pushoverToken;
let pTitle = args.title;
let pMessage = args.message;
Expand All @@ -96,13 +108,10 @@ class MyApp extends Homey.App {
.catch (function(err){
console.log(err)
})

})
}

}


// Send notification with parameters
function pushoverSend(pUser, pToken, pMessage, pTitle, pPriority, pRetry, pExpire, pSound, image) {
let priority = 0;
Expand All @@ -124,12 +133,7 @@ function pushoverSend(pUser, pToken, pMessage, pTitle, pPriority, pRetry, pExpir
break;
}
if (pToken != "") {

let p = new push({
user: pUser,
token: pToken,
});

let p = new push({ user: pUser, token: pToken, });
let msg = {
// These values correspond to the parameters detailed on https://pushover.net/api
// 'message' is required. All other values are optional.
Expand All @@ -141,7 +145,7 @@ function pushoverSend(pUser, pToken, pMessage, pTitle, pPriority, pRetry, pExpir
sound: pSound,
attachment: image
};
// console.log(`Message: ${pMessage}, Title: ${pTitle}, Priority: ${priority}, Retry: ${pRetry}, Expire: ${pExpire}, Sound: ${pSound}"`);
// console.log(`ID: ${pUser}, Token: ${pToken}, Message: ${pMessage}, Title: ${pTitle}, Priority: ${priority}, Retry: ${pRetry}, Expire: ${pExpire}, Sound: ${pSound}"`);
p.send(msg, function (err, result) {
if (err) {
throw err;
Expand Down Expand Up @@ -195,10 +199,7 @@ function pushoverSend_device(pUser, pToken, pMessage, pTitle, pDevice, pPriority
break;
}
if (pToken != "") {
let p = new push({
user: pUser,
token: pToken,
});
let p = new push({ user: pUser, token: pToken, });

let msg = {
// These values correspond to the parameters detailed on https://pushover.net/api
Expand Down Expand Up @@ -233,7 +234,6 @@ function pushoverSend_device(pUser, pToken, pMessage, pTitle, pDevice, pPriority
return Promise.resolve()
}


// Create Insight log
function createInsightlog() {

Expand All @@ -260,6 +260,7 @@ function buildPushoverArray() {

if (account != null) {
pushoverUser = account['user'];
pushoverGroup = account['group'];
pushoverToken = account['token'];
ledringPreference = account['ledring'];

Expand Down
Loading

0 comments on commit 1f1777d

Please sign in to comment.