envoycharts

package module
v0.0.0-...-74ee806 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2023 License: BSD-2-Clause Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

EnvoyCharts

A small data tracking/charting tool for envoy IQ solar systems

envoy-chart does two things

  • runs in the background and polls the envoy every 10 minutes, putting that data into a database
  • acts as a web server which displays the charts

Still a work-in-progress

I'm just getting started.

Right now it supports a single graph (past 24-hours). I will work on adding 7-day and monthly graphs as well, after I collect enough data from my own system.

Design decisions (or indecisions)

  • 10 minute sampling frequency seems good enough. During initial testing I did every minute, but the graph isn't any more informative at this higher frequency, so I'll stick with 10 minutes for now. Eventually it will be configurable.
  • go-echarts spits out Javascript Apache echarts (an older version at that). It seems nice enough for our purposes and is very simple to work with.
  • sqlite because it works ; early experiments with objectbox were fun, but it was too fiddly for me
  • go, because I like go

To Do

  • not have all the parameters hard coded, especially the hostname/ip address
  • implement dns-sd in the go-envoy package so you don't have to set a hostname/ip at all
  • more charts

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Barchart

func Barchart(w io.Writer, samples []*Sample, title string, tz *time.Location)

Barchart takes a set of samples, and a title and writes the barchart to the specified writer

func Linechart

func Linechart(w io.Writer, samples []*Sample, title string, tz *time.Location)

Linechart takes a set of samples, and a title and writes the linechart to the specified writer

func LinechartDaily

func LinechartDaily(w io.Writer, samples []*Daily, title string, tz *time.Location)

LinechartDaily takes a set of daily values, and a title and writes the linechart to the specified writer

Types

type Client

type Client struct {
	DB    *sql.DB
	Envoy *envoy.Envoy
	TZ    *time.Location
	// contains filtered or unexported fields
}

Client is the primary handle for the EnvoyChart API

func New

func New(host string) (*Client, error)

New creates a new Client

func (*Client) Close

func (c *Client) Close()

func (*Client) Configured

func (c *Client) Configured() bool

func (*Client) GetAllDaily

func (c *Client) GetAllDaily() ([]*Daily, error)

GetAllDaily gets every entry from the daily table

func (*Client) GetAllSamples

func (c *Client) GetAllSamples() ([]*Sample, error)

GetAll returns all values from the database, probably not useful for anything other than testing

func (*Client) GetDay

func (c *Client) GetDay(t time.Time) ([]*Sample, error)

GetDay returns all the samples for the day which contains the parameter -- 24 hour window rounded to midnight

func (*Client) GetDayRange

func (c *Client) GetDayRange(start time.Time, end time.Time) ([]*Sample, error)

GetDayRange gets all values between the start and end days -- rounds to start/end of days

func (*Client) GetPastDay

func (c *Client) GetPastDay() ([]*Sample, error)

GetPastDay gets the samples for the previous 24 hours -- 24 hour window ending at Now()

func (*Client) GetSamples

func (c *Client) GetSamples(start, end time.Time) ([]*Sample, error)

func (*Client) PutDaily

func (c *Client) PutDaily(d *Daily) error

func (*Client) PutSample

func (c *Client) PutSample(s *Sample) error

func (*Client) Reset

func (c *Client) Reset() error

func (*Client) Sample

func (c *Client) Sample() error

Sample polls an envoy device and stores the production values into the database

type Daily

type Daily struct {
	Id             int64
	Date           time.Time
	ProductionkWh  float64
	ConsumptionkWh float64
}

type Sample

type Sample struct {
	Id           int64
	Date         time.Time
	ProductionW  float64
	ConsumptionW float64
	NetW         float64
}

Directories

Path Synopsis
cmd
envoy-chart command
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址