Skip to content

Commit

Permalink
Support for pushover notification sounds (#4)
Browse files Browse the repository at this point in the history
* Support for pushover notification sounds

* fix whitespace..
  • Loading branch information
alec-pinson authored Mar 26, 2023
1 parent 34ab89f commit ee30fa7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@

# Go workspace file
go.work
cmd/terrarium-bot-v2/test.yaml
1 change: 1 addition & 0 deletions cmd/terrarium-bot-v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Notification struct {
Id string `yaml:"id"`
AntiSpam time.Duration `yaml:"antiSpam"`
Device string `yaml:"device"`
Sound string `yaml:"sound"`
UserToken string `yaml:"userToken"`
APIToken string `yaml:"apiToken"`
UserTokenValue string
Expand Down
2 changes: 2 additions & 0 deletions cmd/terrarium-bot-v2/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ notification:
- id: "notification1"
antiSpam: "30s"
device: "my_device"
sound: "some_sound"
userToken: "NOTIFICATION_USER_TOKEN"
apiToken: "NOTIFICATION_API_TOKEN"
alert:
Expand Down Expand Up @@ -149,6 +150,7 @@ useInMemoryStatus: true`
assert.Equal(t, "notification1", loadedConfig.Notification[0].Id)
assert.Equal(t, 30*time.Second, loadedConfig.Notification[0].AntiSpam)
assert.Equal(t, "my_device", loadedConfig.Notification[0].Device)
assert.Equal(t, "some_sound", loadedConfig.Notification[0].Sound)
assert.Equal(t, "NOTIFICATION_USER_TOKEN", loadedConfig.Notification[0].UserToken)
assert.Equal(t, "NOTIFICATION_API_TOKEN", loadedConfig.Notification[0].APIToken)
assert.Equal(t, "user123", loadedConfig.Notification[0].UserTokenValue)
Expand Down
1 change: 1 addition & 0 deletions cmd/terrarium-bot-v2/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ sensor:
notification:
- id: pushover
device: Alec-Phone
sound: tugboat
userToken: PUSHOVER_USER_TOKEN # env variable name
apiToken: PUSHOVER_APP_TOKEN # env variable name
antiSpam: 1h # only receive alerts once an hour
Expand Down
1 change: 1 addition & 0 deletions cmd/terrarium-bot-v2/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func PushoverNotification(n Notification, alertMessage string) {
message := &pushover.Message{
Message: alertMessage,
DeviceName: n.Device,
Sound: n.Sound,
}

response, err := app.SendMessage(message, recipient)
Expand Down

0 comments on commit ee30fa7

Please sign in to comment.