gmg

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

Green Mountain Grill

Observe and Control your grill with Go

Note: this was tested on my grill which is a Daniel Boone Prime purchased in 2021. I'm not sure if this will work properly on other models.

Still a work in progress so feel free to assist with building this codebase, any help would be appreciated

Grill Client

// Client - Green Mountain Grill client interface definition
type Client interface {
	IsAvailable() bool
	GetState() (*State, error)
	GetID() ([]byte, error)
	GetFirmware() ([]byte, error)
	SetGrillTemp(temp int) error
	SetProbe1Target(temp int) error
	SetProbe2Target(temp int) error
	PowerOn() error
	PowerOnColdSmoke() error
	PowerOff() error
}

// Params - Parameters to build a new Client
type Params struct {
	GrillIP         net.IP
	GrillPort       int
	Logger          *logrus.Logger
	ReadTimeout     time.Duration // default 2 seconds
	WriteTimeout    time.Duration // default 1 second
	MaxConnAttempts int           // default 5
}

Building a new client

import gmg "github.com/brandenc40/green-mountain-grill"

params := gmg.Params{
	GrillIP:   "192.168.1.2", // example, this will change
	GrillPort: "8080", // this should be the same for all grills... I think...
}
client := gmg.New(params)

Web Server

WORK IN PROGRESS

Planned features to add:

  • track temp over time
  • alerts for when temps are reached

Grill State Data Parse

Shout out to https://github.com/Aenima4six2/gmg and https://github.com/FeatherKing/grillsrv for doing a lot of the leg work on figuring out the commands to send and the data returned by the grill.

EXAMPLE: GRILL OFF
INDEX:  0  1  2  3 4  5 6   7 8 9  10 11 12 13 14 15 16 17 18 19 20  21  22  23  24 25 26 27 28 29 30 31 32 33 34 35
BYTES: [85 82 97 0 89 2 150 0 5 11 20 50 25 25 25 25 89 2  0  0  255 255 255 255 0  0  0  0  0  0  0  0  1  0  0  3 ]

VALUE INDICIES
grillTemp         = 2
grillTempHigh     = 3
probeTemp         = 4
probeTempHigh     = 5
grillSetTemp      = 6
grillSetTempHigh  = 7
probe2Temp        = 16
probe2TempHigh    = 17
probe2SetTemp     = 18
probe2SetTempHigh = 19
curveRemainTime   = 20 // not validated
warnCode          = 24
probeSetTemp      = 28
probeSetTempHigh  = 29
powerState        = 30
grillMode         = 31 // not validated
fireState         = 32
fileStatePercent  = 33 // not validated
profileEnd        = 34 // not validated
grillType         = 35 // not validated

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	IsAvailable() bool
	GetState() (*State, error)
	GetID() ([]byte, error)
	GetFirmware() ([]byte, error)
	SetGrillTemp(temp int) error
	SetProbe1Target(temp int) error
	SetProbe2Target(temp int) error
	PowerOn() error
	PowerOnColdSmoke() error
	PowerOff() error
}

Client - Green Mountain Grill client interface definition

func New

func New(p Params) Client

New -

type Command

type Command string

Command -

const (
	CommandGetInfo          Command = "URCV!"
	CommandGetGrillID       Command = "UL!"
	CommandGetGrillFirmware Command = "UN!"
	CommandSetGrillTemp     Command = "UT%03d!"
	CommandSetProbe1Temp    Command = "UF%03d!"
	CommandSetProbe2Temp    Command = "Uf%03d!"
	CommandPowerOn          Command = "UK001!"
	CommandPowerOnColdSmoke Command = "UK002!"
	CommandPowerOff         Command = "UK004!"
)

Commands that are accepted by the Green Mountain Grill

func (Command) Build

func (c Command) Build(args ...interface{}) []byte

Build -

type FireState

type FireState int

FireState -

const (
	FireStateDefault FireState = iota
	FireStateOff
	FireStateStartup
	FireStateRunning
	FireStateCoolDown
	FireStateFail
	FireStateColdSmoke FireState = 198
)

FireState enum values

func FireStateString

func FireStateString(s string) (FireState, error)

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

func FireStateValues

func FireStateValues() []FireState

FireStateValues returns all values of the enum

func (FireState) IsAFireState

func (i FireState) IsAFireState() bool

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

func (FireState) MarshalJSON

func (i FireState) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for FireState

func (*FireState) Scan

func (i *FireState) Scan(value interface{}) error

func (FireState) String

func (i FireState) String() string

func (*FireState) UnmarshalJSON

func (i *FireState) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for FireState

func (FireState) Value

func (i FireState) Value() (driver.Value, error)

type GrillUnreachableErr

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

func (GrillUnreachableErr) Error

func (g GrillUnreachableErr) Error() string

type Params

type Params struct {
	GrillIP         net.IP
	GrillPort       int
	Logger          *logrus.Logger
	ReadTimeout     time.Duration // default 2 seconds
	WriteTimeout    time.Duration // default 1 second
	MaxConnAttempts int           // default 5
}

Params - Parameters to build a new Client

type PowerState

type PowerState int

PowerState -

const (
	PowerStateOff PowerState = iota
	PowerStateOn
	PowerStateFan
	PowerStateColdSmoke
)

PowerState enum values

func PowerStateString

func PowerStateString(s string) (PowerState, error)

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

func PowerStateValues

func PowerStateValues() []PowerState

PowerStateValues returns all values of the enum

func (PowerState) IsAPowerState

func (i PowerState) IsAPowerState() bool

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

func (PowerState) MarshalJSON

func (i PowerState) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for PowerState

func (*PowerState) Scan

func (i *PowerState) Scan(value interface{}) error

func (PowerState) String

func (i PowerState) String() string

func (*PowerState) UnmarshalJSON

func (i *PowerState) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for PowerState

func (PowerState) Value

func (i PowerState) Value() (driver.Value, error)

type State

type State struct {
	CurrentTemperature      int        `json:"current_temperature"`
	TargetTemperature       int        `json:"target_temperature"`
	Probe1Temperature       int        `json:"probe1_temperature"`
	Probe1TargetTemperature int        `json:"probe1_target_temperature"`
	Probe2Temperature       int        `json:"probe2_temperature"`
	Probe2TargetTemperature int        `json:"probe2_target_temperature"`
	WarnCode                WarnCode   `json:"warn_code"`
	PowerState              PowerState `json:"power_state"`
	FireState               FireState  `json:"fire_state"`
}

State - The current state of the grill

func GetStateResponseToState

func GetStateResponseToState(response []byte) *State

GetStateResponseToState -

func (*State) IsOn

func (s *State) IsOn() bool

IsOn - true if the grill is turned on

type WarnCode

type WarnCode int

WarnCode -

const (
	WarnCodeNone               WarnCode = 0
	WarnCodeFanMotorOverload   WarnCode = 1
	WarnCodeAugerMotorOverload WarnCode = 2
	WarnCodeLowVoltage         WarnCode = 4
	WarnCodeIgniterOverload    WarnCode = 8
	WarnCodeLowPellet          WarnCode = 128
)

WarnCode enum values TODO: VALIDATE, CURRENTLY NOT VALIDATED FOR ALL ERROR CODES

func WarnCodeString

func WarnCodeString(s string) (WarnCode, error)

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

func WarnCodeValues

func WarnCodeValues() []WarnCode

WarnCodeValues returns all values of the enum

func (WarnCode) IsAWarnCode

func (i WarnCode) IsAWarnCode() bool

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

func (WarnCode) MarshalJSON

func (i WarnCode) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for WarnCode

func (*WarnCode) Scan

func (i *WarnCode) Scan(value interface{}) error

func (WarnCode) String

func (i WarnCode) String() string

func (*WarnCode) UnmarshalJSON

func (i *WarnCode) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for WarnCode

func (WarnCode) Value

func (i WarnCode) Value() (driver.Value, error)

Directories

Path Synopsis
cmd
app

Jump to

Keyboard shortcuts

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