Pushover: add devices (#5948)

This commit is contained in:
andig 2023-01-30 18:28:47 +01:00 • committed by GitHub
parent ee12a544a8
commit 145cebea2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ package push
import (
"errors"
"strings"
"github.com/evcc-io/evcc/util"
"github.com/gregdel/pushover"
@ -15,6 +16,7 @@ func init() {
type PushOver struct {
log *util.Logger
app *pushover.Pushover
device string
recipients []string
}
@ -23,6 +25,7 @@ func NewPushOverFromConfig(other map[string]interface{}) (Messenger, error) {
var cc struct {
App string
Recipients []string
Devices []string
Events map[string]EventTemplate
}
@ -37,6 +40,7 @@ func NewPushOverFromConfig(other map[string]interface{}) (Messenger, error) {
m := &PushOver{
log: util.NewLogger("pushover"),
app: pushover.New(cc.App),
device: strings.Join(cc.Devices, ","),
recipients: cc.Recipients,
}
@ -46,6 +50,7 @@ func NewPushOverFromConfig(other map[string]interface{}) (Messenger, error) {
// Send sends to all receivers
func (m *PushOver) Send(title, msg string) {
message := pushover.NewMessageWithTitle(msg, title)
message.DeviceName = m.device
for _, id := range m.recipients {
go func(id string) {