Add Tasmota timezone handling and dashboard updates
This commit is contained in:
@@ -21,18 +21,19 @@ type writer interface {
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
config config.Config
|
||||
deviceAliases map[string]string
|
||||
aliasRecords []model.Record
|
||||
snapshots map[string]*deviceSnapshot
|
||||
dirtyDevices map[string]struct{}
|
||||
influxClient writer
|
||||
input chan model.RawMessage
|
||||
received atomic.Uint64
|
||||
parsed atomic.Uint64
|
||||
written atomic.Uint64
|
||||
dropped atomic.Uint64
|
||||
failed atomic.Uint64
|
||||
config config.Config
|
||||
tasmotaTimeLocation *time.Location
|
||||
deviceAliases map[string]string
|
||||
aliasRecords []model.Record
|
||||
snapshots map[string]*deviceSnapshot
|
||||
dirtyDevices map[string]struct{}
|
||||
influxClient writer
|
||||
input chan model.RawMessage
|
||||
received atomic.Uint64
|
||||
parsed atomic.Uint64
|
||||
written atomic.Uint64
|
||||
dropped atomic.Uint64
|
||||
failed atomic.Uint64
|
||||
}
|
||||
|
||||
type Snapshot struct {
|
||||
@@ -55,13 +56,14 @@ type deviceSnapshot struct {
|
||||
func NewService(cfg config.Config, influxClient writer) *Service {
|
||||
normalizedAliases := normalizeDeviceAliases(cfg.DeviceAliases)
|
||||
return &Service{
|
||||
config: cfg,
|
||||
deviceAliases: normalizedAliases,
|
||||
aliasRecords: buildAliasRecords(normalizedAliases),
|
||||
snapshots: make(map[string]*deviceSnapshot),
|
||||
dirtyDevices: make(map[string]struct{}),
|
||||
influxClient: influxClient,
|
||||
input: make(chan model.RawMessage, cfg.App.BufferSize),
|
||||
config: cfg,
|
||||
tasmotaTimeLocation: cfg.App.TasmotaLocation(),
|
||||
deviceAliases: normalizedAliases,
|
||||
aliasRecords: buildAliasRecords(normalizedAliases),
|
||||
snapshots: make(map[string]*deviceSnapshot),
|
||||
dirtyDevices: make(map[string]struct{}),
|
||||
influxClient: influxClient,
|
||||
input: make(chan model.RawMessage, cfg.App.BufferSize),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +115,7 @@ func (service *Service) Run(ctx context.Context) error {
|
||||
service.logCounters()
|
||||
return nil
|
||||
case message := <-input:
|
||||
records, err := parser.ParseTasmota(message)
|
||||
records, err := parser.ParseTasmotaInLocation(message, service.tasmotaTimeLocation)
|
||||
if err != nil {
|
||||
service.failed.Add(1)
|
||||
slog.Warn("failed to parse message", "topic", message.Topic, "error", err)
|
||||
|
||||
Reference in New Issue
Block a user