# README
Saves TIC events to TimescaleDB
Testing
podman-compose up -d
go run cli/main.go process
declare -a fields=(IINST IINST1 IINST2 IINST3 PAPP BASE HCHP HCHC)
while sleep 1; do
value=$((1 + RANDOM % 100))
field=${fields[1 + $((RANDOM % ${#fields[@]}))]}
echo "{\"ts\":$EPOCHSECONDS,\"val\":\"$(printf %03d $value)\"}" | pub -broker mqtt://localhost:1883 -topic esp-tic/status/tic/$field -username dev -password secret -qos 1
done
# Packages
Copyright © 2022 Nicolas MASSE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
# Functions
MigrateDb migrates the provided database to the most recent schema.
NewMqttClient creates a new MQTT client and connects to the broker.
NewProcessor creates a new processor from its configuration.
SetMqttLogger sets the logger to be used by the underlying MQTT library.
# Constants
How many in-flight MQTT messages to buffer.
QoS 1.
QoS 2.
QoS 3.
SQL Query to store current data.
SQL Query to store energy data.
SQL Query to store power data.
# Variables
SqlMigrationFS stores a list of database schema migration scriptsgo:embed schemas/*.sql.
# Structs
An MqttConfig represents the required information to connect to an MQTT broker.
A Processor receives events from the MQTT broker and saves data to the database.
A ProcessorConfig stores the configuration of a processor.
An SqlConfig stores connection details to the database.
A TicMessage represents data received from the TIC (Tele Information Client).
# Type aliases
A UnixEpoch is a time.Time that serializes / deserializes as Unix epoch.