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

Add MQTT support #98

Merged
merged 9 commits into from
Apr 5, 2024
Prev Previous commit
Update internal/analysis/processor/actions.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
tphakala and coderabbitai[bot] authored Apr 5, 2024
commit 0551f709cf9556131415a95f78c33ead516bf5fd
16 changes: 16 additions & 0 deletions internal/analysis/processor/actions.go
Original file line number Diff line number Diff line change
@@ -150,6 +150,22 @@ func (a BirdWeatherAction) Execute(data interface{}) error {
}

// Execute sends the note to the MQTT broker
import (
"errors"
"encoding/json"
"fmt"
"log"
"strings"
"time"

"github.com/tphakala/birdnet-go/internal/birdnet"
"github.com/tphakala/birdnet-go/internal/birdweather"
"github.com/tphakala/birdnet-go/internal/conf"
"github.com/tphakala/birdnet-go/internal/datastore"
"github.com/tphakala/birdnet-go/internal/mqtt"
"github.com/tphakala/birdnet-go/internal/myaudio"
"github.com/tphakala/birdnet-go/internal/observation"
)
func (a MqttAction) Execute(data interface{}) error {
if a.Settings.Realtime.MQTT.Topic == "" {
return errors.New("MQTT topic is not specified")

Unchanged files with check annotations Beta

// conf/config.go

Check failure on line 1 in internal/conf/config.go

GitHub Actions / lint

: # github.com/tphakala/birdnet-go/internal/conf
package conf
import (
Username string // MQTT username
Password string // MQTT password
}
func Load() (*Settings, error) {

Check failure on line 80 in internal/conf/config.go

GitHub Actions / lint

syntax error: unexpected func, expected field name or embedded type

Check failure on line 80 in internal/conf/config.go

GitHub Actions / lint

expected '}', found 'func' (typecheck)

Check failure on line 80 in internal/conf/config.go

GitHub Actions / lint

syntax error: unexpected func, expected field name or embedded type
settings := &Settings{}
if err := initViper(); err != nil {

Check failure on line 82 in internal/conf/config.go

GitHub Actions / lint

syntax error: unexpected if, expected field name or embedded type

Check failure on line 82 in internal/conf/config.go

GitHub Actions / lint

expected '}', found 'if' (typecheck)

Check failure on line 82 in internal/conf/config.go

GitHub Actions / lint

syntax error: unexpected if, expected field name or embedded type
return nil, fmt.Errorf("error initializing viper: %w", err)

Check failure on line 83 in internal/conf/config.go

GitHub Actions / lint

syntax error: unexpected comma in struct type; possibly missing semicolon or newline or } (typecheck)

Check failure on line 83 in internal/conf/config.go

GitHub Actions / lint

expected declaration, found 'return' (typecheck)
}
if err := viper.Unmarshal(settings); err != nil {
return nil, fmt.Errorf("error unmarshaling config into struct: %w", err)
"strconv"
"time"
"github.com/tphakala/birdnet-go/internal/conf"

Check failure on line 10 in internal/datastore/interfaces.go

GitHub Actions / lint

could not import github.com/tphakala/birdnet-go/internal/conf (-: # github.com/tphakala/birdnet-go/internal/conf
"gorm.io/gorm"
"gorm.io/gorm/logger"
)