Documentation
¶
Index ¶
- func GenerateConfig(config Config, ...)
- type Config
- type Controller
- func (c *Controller) AssertLightActions(t *testing.T, expected ...action.LightAction)
- func (c *Controller) AssertStopActions(t *testing.T, expected int)
- func (c *Controller) AssertStopAllActions(t *testing.T, expected int)
- func (c *Controller) AssertWaterActions(t *testing.T, expected ...action.WaterMessage)
- func (c *Controller) PublishStartupLog(topicPrefix string) error
- func (c *Controller) Start()
- func (c *Controller) Stop()
- type NestedConfig
- type WifiConfig
- type ZoneConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateConfig ¶
func GenerateConfig(config Config, writeFile, genWifiConfig, genMainConfig, overwrite, interactive bool)
GenerateConfig will create config.h and wifi_config.h based on the provided configurations. It can optionally write to files instead of stdout
Types ¶
type Config ¶
type Config struct {
MQTTConfig mqtt.Config `mapstructure:"mqtt"`
NestedConfig `mapstructure:"controller"`
LogConfig server.LogConfig `mapstructure:"log"`
}
Config holds all the options and sub-configs for the mock controller
type Controller ¶
type Controller struct {
Config
// contains filtered or unexported fields
}
Controller struct holds the necessary data for running the mock garden-controller
func NewController ¶
func NewController(cfg Config) (*Controller, error)
NewController creates and initializes everything needed to run a Controller based on config
func (*Controller) AssertLightActions ¶
func (c *Controller) AssertLightActions(t *testing.T, expected ...action.LightAction)
AssertLightActions is used to check that all expected LightActions were received, then reset recorded info
func (*Controller) AssertStopActions ¶
func (c *Controller) AssertStopActions(t *testing.T, expected int)
AssertStopActions is used to check that the expected number of StopActions were received, then reset recorded info
func (*Controller) AssertStopAllActions ¶
func (c *Controller) AssertStopAllActions(t *testing.T, expected int)
AssertStopAllActions is used to check that the expected number of StopAllActions were received, then reset recorded info
func (*Controller) AssertWaterActions ¶
func (c *Controller) AssertWaterActions(t *testing.T, expected ...action.WaterMessage)
AssertWaterActions is used to check that all expected WaterMessages were received, then reset recorded info
func (*Controller) PublishStartupLog ¶
func (c *Controller) PublishStartupLog(topicPrefix string) error
PublishStartupLog publishes the message that controllers use to signal that they started up
func (*Controller) Start ¶
func (c *Controller) Start()
Start will run the Controller until it is stopped (blocking)
type NestedConfig ¶
type NestedConfig struct {
// Configs used only for running mock controller
EnableUI bool `mapstructure:"enable_ui" survey:"enable_ui"`
PublishWaterEvent bool `mapstructure:"publish_water_event" survey:"publish_water_event"`
TemperatureValue float64 `mapstructure:"temperature_value"`
HumidityValue float64 `mapstructure:"humidity_value"`
TemperatureHumidityDisableNoise bool `mapstructure:"temperature_humidity_disable_noise"`
// Configs used for both
TopicPrefix string `mapstructure:"topic_prefix" survey:"topic_prefix"`
NumZones int `mapstructure:"num_zones" survey:"num_zones"`
PublishHealth bool `mapstructure:"publish_health" survey:"publish_health"`
HealthInterval time.Duration `mapstructure:"health_interval" survey:"health_interval"`
PublishTemperatureHumidity bool `mapstructure:"publish_temperature_humidity" survey:"publish_temperature_humidity"`
TemperatureHumidityInterval time.Duration `mapstructure:"temperature_humidity_interval" survey:"temperature_humidity_interval"`
// Configs only used for generate-config
WifiConfig `mapstructure:"wifi" survey:"wifi"`
Zones []ZoneConfig `mapstructure:"zones" survey:"zones"`
LightPin string `mapstructure:"light_pin" survey:"light_pin"`
TemperatureHumidityPin string `mapstructure:"temperature_humidity_pin" survey:"temperature_humidity_pin"`
MQTTAddress string `survey:"mqtt_address"`
MQTTPort int `survey:"mqtt_port"`
}
NestedConfig is an unfortunate struct that I had to create to have this nested under the 'controller' key in the YAML config
type WifiConfig ¶
type WifiConfig struct {
SSID string `mapstructure:"ssid"`
Password string `mapstructure:"password"`
}
WifiConfig holds WiFi connection details
type ZoneConfig ¶
type ZoneConfig struct {
PumpPin string `mapstructure:"pump_pin" survey:"pump_pin"`
ValvePin string `mapstructure:"valve_pin" survey:"valve_pin"`
}
ZoneConfig has the configuration details for controlling hardware pins