Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for pushover notification sounds #4

Merged
merged 2 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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