wifire

package module
v0.8.1-0...-1b9a3b4 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: BSD-3-Clause Imports: 25 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

This section is empty.

Functions

func ClientID

func ClientID(id string) func(*Client)

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(*Client)

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 SystemStatusStrings

func SystemStatusStrings() []string

SystemStatusStrings returns a slice of all String values of the enum

func URLs

func URLs(base string) func(*Client)

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

func UnitsStrings

func UnitsStrings() []string

UnitsStrings returns a slice of all String values of the enum

func WithLogger

func WithLogger(logger *slog.Logger) func(*Client)

WithLogger is an option setting function for New(). It sets the logger used by the WiFire client.

Types

type Client

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

Client is a handle for the Client API connection.

func NewClient

func NewClient(opts ...func(*Client)) (*Client, error)

NewClient returns a new WiFire connection or an error.

func (*Client) MQTTConnect

func (c *Client) MQTTConnect() error

MQTTConnect establishes the MQTT connection to the Grill.

func (*Client) MQTTDisconnect

func (c *Client) MQTTDisconnect()

MQTTDisconnect closed the MQTT connection to the Grill.

func (*Client) MQTTIsConnected

func (c *Client) MQTTIsConnected() bool

func (*Client) MQTTSubscribeStatus

func (c *Client) MQTTSubscribeStatus(grill string, subscriber chan Status) error

MQTTSubscribeStatus subscribes to the prod/thing/update for the grill. Updates are pushed to the returned channel.

func (*Client) UserData

func (c *Client) UserData() (*GetUserDataResponse, error)

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

type ExponentialPredictor

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

ExponentialPredictor implements an exponential approach model for cooking temperature prediction Based on the physics that food temperature approaches an equilibrium temperature exponentially Considers grill temperature, grill set point, and heat transfer dynamics

func NewExponentialPredictor

func NewExponentialPredictor() *ExponentialPredictor

NewExponentialPredictor creates a new exponential approach predictor

func (*ExponentialPredictor) EstimateTimeToTarget

func (ep *ExponentialPredictor) EstimateTimeToTarget(targetTemp float64) time.Duration

EstimateTimeToTarget estimates the time required to reach a target temperature using grill dynamics

func (*ExponentialPredictor) GetCurrentState

func (ep *ExponentialPredictor) GetCurrentState() (temperature, velocity float64)

GetCurrentState returns the current filtered temperature and velocity

func (*ExponentialPredictor) GetTimeConstant

func (ep *ExponentialPredictor) GetTimeConstant() float64

GetTimeConstant returns the current time constant (for debugging)

func (*ExponentialPredictor) GetUncertainty

func (ep *ExponentialPredictor) GetUncertainty() float64

GetUncertainty returns an estimate of prediction uncertainty

func (*ExponentialPredictor) IsInitialized

func (ep *ExponentialPredictor) IsInitialized() bool

IsInitialized returns whether the predictor has been initialized

func (*ExponentialPredictor) PredictTemperature

func (ep *ExponentialPredictor) PredictTemperature(futureTime time.Time) float64

PredictTemperature predicts the temperature at a future time using grill dynamics

func (*ExponentialPredictor) Update

func (ep *ExponentialPredictor) Update(probeTemp float64, timestamp time.Time, probeTargetTemp, grillTemp, grillSetTemp float64)

Update processes a new temperature measurement and updates the model Now considers grill temperature and grill set point for more accurate prediction

type GetUserDataResponse

type GetUserDataResponse struct {
	Cognito        string  `json:"cognito"`
	CustomerID     string  `json:"customerId"`
	Email          string  `json:"email"`
	FamiltyName    string  `json:"familyName"`
	FullName       string  `json:"fullName"`
	GivenName      string  `json:"givenName"`
	Teams          []team  `json:"teams"`
	Things         []thing `json:"things"`
	UrbanAirshipID string  `json:"urbanAirshipId"`
	UserID         string  `json:"userId"`
	Username       string  `json:"username"`
}

GetUserDataResponse is the wifire UserData.

type Marker

type Marker struct {
	Label string
	Time  time.Time
}

Marker is an annotation point on the graph.

type Period

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

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

Plotter creates a graph of the wifire Status data.

func NewPlotter

func NewPlotter(options *PlotterOptions) *Plotter

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

func (*Plotter) Plot

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

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

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"` // TODO: next smoke use keep warm to see if this is a bool
	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"`
	Smoke           int           `json:"smoke,omitempty"`
	Time            time.Time     `json:"time"`
	Units           Units         `json:"units"`
	SystemStatus    SystemStatus  `json:"system_status"`
	ProbeETA        time.Duration `json:"probe_eta,omitempty,format:units"`
}

Status is the real-time grill status. It is a cleaned up version of the status returned from the MQTT subscription. If there was an error receiving the message the Error field is set.

The ProbeETA field is calculated separately and is included here for logging.

type SystemStatus

type SystemStatus int
const (
	StatusSleeping SystemStatus // sleeping
	StatusReady                 // ready
	StatusIgniting              // igniting
	StatusHeating               // heating
	StatusCooking               // cooking

	StatusKeepWarm // keep warm
	StatusShutdown // shutdown

	StatusOffline SystemStatus = 99 // offline
)

func SystemStatusString

func SystemStatusString(s string) (SystemStatus, error)

SystemStatusString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func SystemStatusValues

func SystemStatusValues() []SystemStatus

SystemStatusValues returns all values of the enum

func (SystemStatus) IsASystemStatus

func (i SystemStatus) IsASystemStatus() bool

IsASystemStatus returns "true" if the value is listed in the enum definition. "false" otherwise

func (SystemStatus) MarshalText

func (s SystemStatus) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface for s.

func (SystemStatus) String

func (i SystemStatus) String() string

func (*SystemStatus) UnmarshalText

func (s *SystemStatus) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for s.

type Units

type Units int
const (
	UnitsCelsius    Units = iota // celsius
	UnitsFahrenheit              // fahrenheit
)

func UnitsString

func UnitsString(s string) (Units, error)

UnitsString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func UnitsValues

func UnitsValues() []Units

UnitsValues returns all values of the enum

func (Units) IsAUnits

func (i Units) IsAUnits() bool

IsAUnits returns "true" if the value is listed in the enum definition. "false" otherwise

func (Units) MarshalText

func (u Units) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface for u.

func (Units) String

func (i Units) String() string

func (*Units) UnmarshalText

func (u *Units) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for u.

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