action

package
v0.0.0-...-9a5a174 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GardenAction

type GardenAction struct {
	Light  *LightAction  `json:"light" form:"light"`
	Stop   *StopAction   `json:"stop" form:"stop"`
	Update *UpdateAction `json:"update" form:"update"`
}

GardenAction collects all the possible actions for a Garden into a single struct so these can easily be received as one request

func (*GardenAction) Bind

func (action *GardenAction) Bind(_ *http.Request) error

Bind is used to make this struct compatible with our REST API implemented with go-chi. It will verify that the request is valid

func (*GardenAction) String

func (action *GardenAction) String() string

String...

type LightAction

type LightAction struct {
	State pkg.LightState `json:"state" form:"state"`
}

LightAction is an action for turning on or off a light for the Garden. The State field is optional and it will just toggle the current state if left empty.

type Source

type Source string

Source shows how an action was triggered

const (
	SourceSchedule     Source = "schedule"
	SourceCommand      Source = "command"
	SourceWaterRoutine Source = "water_routine"
)

type StopAction

type StopAction struct {
	All bool `json:"all" form:"all"`
}

StopAction is an action for stopping watering of a Zone. It doesn't stop watering a specific Zone, only what is currently watering and optionally clearing the queue of Zones to water.

type UpdateAction

type UpdateAction struct {
	Config bool `json:"config" form:"config"`
}

Update action is used to send the Garden's current ControllerConfig to the the controller

type WaterAction

type WaterAction struct {
	Duration      *pkg.Duration `json:"duration" form:"duration"`
	IgnoreWeather bool          `json:"ignore_weather"`

	// Source is only used internally and is not set by incoming commands
	Source Source `json:"-"`
}

WaterAction is an action for watering a Zone for the specified amount of time

type WaterMessage

type WaterMessage struct {
	Duration int64  `json:"duration"`
	ZoneID   string `json:"zone_id"`
	Position uint   `json:"position"`
	EventID  string `json:"id"`
	Source   Source `json:"source"`

	// Start is a boolean showing if this record is the start or finish event. It is excluded
	// from JSON because it is just used when parsing incoming messages that log the start/finish
	Start bool `json:"-"`
}

WaterMessage is the message being sent over MQTT to the embedded garden controller

func (*WaterMessage) String

func (m *WaterMessage) String() string

String...

type ZoneAction

type ZoneAction struct {
	Water *WaterAction `json:"water" form:"water"`
}

ZoneAction collects all the possible actions for a Zone into a single struct so these can easily be received as one request

func (*ZoneAction) Bind

func (action *ZoneAction) Bind(*http.Request) error

Bind is used to make this struct compatible with our REST API implemented with go-chi. It will verify that the request is valid

func (*ZoneAction) String

func (action *ZoneAction) String() string

String...

Jump to

Keyboard shortcuts

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