Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct { // Status describes the condition of the SUD and any alert conditions. Status SUDStatus `json:"S"` // Temperature describes the water temperature in celsius degrees. Temperature float64 `json:"T"` // PH describes the water's PH. PH float64 `json:"P"` // NH3 describes the amount of free ammonia. (See: https://answers.seneye.com/en/water_chemistry/what_is_ammonia_NH3_NH4 ) NH3 float64 `json:"N"` // Kelvin is the numeric Correlated Color Temperature value of the colour temperature in degrees Kelvin. // https://www.seneye.com/kelvin Kelvin float64 `json:"K"` // Lux describes the intensity of the light observed in the tank. ( https://en.wikipedia.org/wiki/Lux ) Lux float64 `json:"L"` // PAR describes the photosynthetic active radiation is a measurement of light power between 400nm and 700nm. // ( https://answers.seneye.com/index.php?title=en/Aquarium_help/What_is_PAR_%26_PUR_%3F ) PAR float64 `json:"A"` }
Data describes readings from the SUD.
type LDE ¶
type LDE struct { // Version of the LDE protocol. Version string `json:"version"` // SUD describes the state of Seneye USB Device. SUD SUD `json:"SUD"` }
LDE is the Seneye Local Data Exchange object.
func FromRequestBody ¶
FromRequestBody parses the LDE body.
type SUD ¶
type SUD struct { // ID describes the serial number of the SUD. ID string `json:"id"` // Name is the user assigned name of the SUD. Name string `json:"name"` // Type describes the seneye device model type. Type SUDType `json:"type"` // Timestamp describes when the sample was taken (UNIX timestamp) Timestamp int64 `json:"TS"` // Data holds the readings from the SUD. Data Data `json:"data"` }
SUD describes the state of Seneye USB Device.
type SUDStatus ¶
type SUDStatus struct { // Water is 1 if the SUD is submerged in water, 0 otherwise. Water int `json:"W"` // Temperature is 0 if the temperature is within limits, 1 otherwise. Temperature int `json:"T"` // PH is 0 if the pH is within limits, 1 otherwise PH int `json:"P"` // NH3 is 0 if the free ammonia is within limits, 1 otherwise NH3 int `json:"N"` // Slide is 0 if the slide is correctly installed and unexpired, 1 otherwise. Slide int `json:"S"` // Kelvin is 0 if the Kelvin measurement is within limits, 1 otherwise. Kelvin int `json:"K"` }
SUDStatus describes the condition of the SUD and any alert conditions.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an HTTP server which implements the Seneye LDE protocol.
func NewServer ¶
func NewServer(options ...ServerOption) *Server
NewServer creates a new LDE Server with the provided options.
func (*Server) Collect ¶
func (l *Server) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector.
func (*Server) Describe ¶
func (l *Server) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector.
type ServerOption ¶
type ServerOption func(*Server)
ServerOption describes a func which implements the functional option pattern for the LDE Server.
func WithPrometheus ¶
func WithPrometheus(reg prometheus.Registerer) ServerOption
WithPrometheus registers the server with a prometheus registry
func WithSecrets ¶
func WithSecrets(secrets map[string][]byte) ServerOption
WithServer sets the JWT validation secrets used to verify the authenticity of an LDE request. Secrets is a map of SUD ID to JWT signing secret, allowing one server to record LDE events for multiple SUDs / Seneye accounts. A default secret for all unspecified SUDs can be set w/ the empty-string for key.