wifire

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

README

GitHub Actions Go Version Go Report Card Go Reference

WiFire

Temperature monitoring for Traeger grills. For use as a library or standalone command.

building

From the root of the project type make to bootstrap the build environment, this will create a .builder directory with a bunch of makefiles. Type make again for help. Use the build target to build the wifire cli.

cli

The wifire command requires both --username and --password flags, use the same credentials used for the Traeger mobile app. With no other options the command will start logging to the terminal received temperature updates from your grill. For example:

2:21PM INF ambient=28 grill=80 grill_set=80 probe=15 probe_alarm=false probe_set=70
2:22PM INF ambient=27 grill=80 grill_set=80 probe=17 probe_alarm=false probe_set=70
2:23PM INF ambient=27 grill=80 grill_set=80 probe=17 probe_alarm=false probe_set=70

Use the --output flag to also log JSON to a file.

Run wifire with no arguments to see the help and usage.

plot

After a session of logging with the --output flag run wifire plot and use the --input flag to specify a JSON log file. The result is a file called wifire.png the will look the following:

sample plot

Documentation

Overview

Package wifire implements a client for connecting to the Traeger REST and MQTT APIs. The goal is to support temperature monitoring with a potential longterm goal of controlling the grill.

Index

Constants

This section is empty.

Variables

View Source
var Logger func(level LogLevel, component string, message string)

Logger is the package global logging handler.

Functions

func ClientID

func ClientID(id string) func(*WiFire)

ClientID is an option setting function for New(). It sets the client identifier for the WiFire API. This should be set to the ID of the Traeger App.

func Credentials

func Credentials(username, password string) func(*WiFire)

Credentials is an option setting function for New(). It sets the user and password credentials for logging into the API. These are the same values used by the Traeger App.

func URLs

func URLs(base, cognito string) func(*WiFire)

URLs is an option setting function for New(). It sets the WiFire API URLs used to pull the user information and obtain a token.

Types

type Grill

type Grill struct {
	// contains filtered or unexported fields
}

Grill is a handle for a grills MQTT connection.

func (*Grill) Connect

func (g *Grill) Connect() error

Connect establishes the MQTT connection to the Grill.

func (Grill) Disconnect

func (g Grill) Disconnect()

Disconnect closed the MQTT connection to the Grill.

func (Grill) SubscribeStatus

func (g Grill) SubscribeStatus(ch chan Status) error

SubscribeStatus subscribes to the prod/thing/update for the grill. SubscribeStatus updates are pushed to the returned channel.

type LogLevel

type LogLevel int

LogLevel is the log level for MQTT calls.

const (

	// LogError maps to mqtt.ERROR and mqtt.CRITICAL.
	LogError LogLevel
	// LogWarn maps to mqtt.WARN.
	LogWarn
	// LogInfo does not have a mqtt level.
	LogInfo
	// LogDebug maps to mqtt.DEBUG.
	LogDebug
)

type Period added in v0.6.0

type Period int

Period is used to set the x-axis time period.

const (
	ByHour Period = iota
	ByMinute
	ByDay
)

The Period can be hours, minutes, or days. The default is hours.

type Plotter added in v0.6.0

type Plotter struct {
	// contains filtered or unexported fields
}

Plotter creates a graph of the wifire Status data.

func NewPlotter added in v0.6.0

func NewPlotter(o PlotterOptions) *Plotter

NewPlotter returns a Plotter configured with the options o. If o is empty the default settings are used.

func (Plotter) Plot added in v0.6.0

func (p Plotter) Plot() (*plot.Plot, error)

Plot returns the plot.Plot for the Status data given to the Plotter. The caller should call plot.Save to create the graph files. This allows the caller to define the Plot size and graphics format.

type PlotterOptions added in v0.6.0

type PlotterOptions struct {
	Title            string
	Period           Period
	AmbientColor     color.Color
	AmbientFillColor color.Color
	ProbeColor       color.Color
	GrillColor       color.Color
	MarkerColor      color.Color
	Data             []Status
	Markers          []time.Duration
}

PlotterOptions is used to configure the Plotter.

type Status

type Status struct {
	Error           error     `json:"error,omitempty"`
	Ambient         int       `json:"ambient"`
	Connected       bool      `json:"connected"`
	Grill           int       `json:"grill"`
	GrillSet        int       `json:"grill_set"`
	KeepWarm        int       `json:"keep_warm,omitempty"`
	PelletLevel     int       `json:"pellet_level,omitempty"`
	Probe           int       `json:"probe,omitempty"`
	ProbeAlarmFired bool      `json:"probe_alarm_fired,omitempty"`
	ProbeConnected  bool      `json:"probe_connected,omitempty"`
	ProbeSet        int       `json:"probe_set,omitempty"`
	RealTime        int       `json:"real_time,omitempty"`
	Smoke           int       `json:"smoke,omitempty"`
	Time            time.Time `json:"time"`
	Units           int       `json:"units"`
}

Status is the grill status returned from the MQTT subscription. If there was an error receiving the message the Error field is set.

type WiFire

type WiFire struct {
	// contains filtered or unexported fields
}

WiFire is a handle for the WiFire API connection.

func New

func New(opts ...func(*WiFire)) (*WiFire, error)

New returns a new WiFire connection or an error.

func (WiFire) NewGrill

func (w WiFire) NewGrill(name string) *Grill

NewGrill returns a Grill with the given name.

func (WiFire) UserData

func (w WiFire) UserData() (*getUserDataResponse, error)

UserData fetches the /prod/users/self information from the WiFire API.

Directories

Path Synopsis
package main implements the wifire cli.
package main implements the wifire cli.

Jump to

Keyboard shortcuts

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