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 ¶
- func ClientID(id string) func(*Client)
- func Credentials(username, password string) func(*Client)
- func SystemStatusStrings() []string
- func URLs(base string) func(*Client)
- func UnitsStrings() []string
- func WithLogger(logger *slog.Logger) func(*Client)
- type Client
- type ExponentialPredictor
- func (ep *ExponentialPredictor) EstimateTimeToTarget(targetTemp float64) time.Duration
- func (ep *ExponentialPredictor) GetCurrentState() (temperature, velocity float64)
- func (ep *ExponentialPredictor) GetTimeConstant() float64
- func (ep *ExponentialPredictor) GetUncertainty() float64
- func (ep *ExponentialPredictor) IsInitialized() bool
- func (ep *ExponentialPredictor) PredictTemperature(futureTime time.Time) float64
- func (ep *ExponentialPredictor) Update(probeTemp float64, timestamp time.Time, ...)
- type GetUserDataResponse
- type Marker
- type Period
- type Plotter
- type PlotterOptions
- type Status
- type SystemStatus
- type Units
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientID ¶
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 ¶
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 ¶
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 ¶
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 (*Client) MQTTConnect ¶
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 (*Client) MQTTSubscribeStatus ¶
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 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.
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
func UnitsString ¶
UnitsString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func (Units) IsAUnits ¶
IsAUnits returns "true" if the value is listed in the enum definition. "false" otherwise
func (Units) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for u.
func (*Units) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for u.
