Add Tasmota timezone handling and dashboard updates

This commit is contained in:
2026-03-16 12:17:40 +01:00
parent 5ac9cc3892
commit 585378297c
10 changed files with 1223 additions and 1027 deletions
+22 -20
View File
@@ -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)