Add configuration options to disable heater/cooler
This commit is contained in:
parent
5b3f7708c0
commit
d873538b70
3 changed files with 16 additions and 9 deletions
|
@ -3,12 +3,13 @@ package main
|
|||
import (
|
||||
"log"
|
||||
|
||||
"git.joco.dk/sng/fermentord/internal/configuration"
|
||||
"git.joco.dk/sng/fermentord/internal/controllers"
|
||||
"git.joco.dk/sng/fermentord/internal/hw"
|
||||
"git.joco.dk/sng/fermentord/internal/metrics"
|
||||
)
|
||||
|
||||
func gpioSetState(state controllers.ChamberState, gpio *hw.Gpio) {
|
||||
func gpioSetState(state controllers.ChamberState, gpio *hw.Gpio, config *configuration.Configuration) {
|
||||
switch state {
|
||||
case controllers.ChamberStateIdle:
|
||||
log.Printf("Setting chamber state idle")
|
||||
|
@ -20,12 +21,16 @@ func gpioSetState(state controllers.ChamberState, gpio *hw.Gpio) {
|
|||
log.Printf("Setting chamber state cooling")
|
||||
metrics.State.Set(metrics.MetricStateCooling)
|
||||
gpio.StopHeater()
|
||||
if config.CoolerEnabled {
|
||||
gpio.StartCooler()
|
||||
}
|
||||
|
||||
case controllers.ChamberStateHeating:
|
||||
log.Printf("Setting chamber state heating")
|
||||
metrics.State.Set(metrics.MetricStateHeating)
|
||||
gpio.StopCooler()
|
||||
if config.HeaterEnabled {
|
||||
gpio.StartHeater()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ func mainLoop(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream, config
|
|||
}
|
||||
|
||||
case state := <-ctrl.C:
|
||||
gpioSetState(state, gpio)
|
||||
gpioSetState(state, gpio, config)
|
||||
ingest.AddState(state)
|
||||
display.SetState(state)
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ type Configuration struct {
|
|||
FermentationTemperature float64 `mapstructure:"fermentation_temp"`
|
||||
DeltaTemperatureCool float64 `mapstructure:"delta_temp_cool"`
|
||||
DeltaTemperatureHeat float64 `mapstructure:"delta_temp_heat"`
|
||||
HeaterDutyCycle time.Duration `mapstructure:"heater_duty_cycle"`
|
||||
HeaterEnabled bool `mapstructure:"heater_enabled"`
|
||||
CoolerEnabled bool `mapstructure:"cooler_enabled"`
|
||||
|
||||
Limits struct {
|
||||
MinChamberTemperature float64 `mapstructure:"min_chamber_temp"`
|
||||
|
@ -56,7 +57,8 @@ func LoadConfiguration() *Configuration {
|
|||
hub := sentry.CurrentHub().Clone()
|
||||
defer hub.Flush(10 * time.Second)
|
||||
|
||||
viper.SetDefault("heater_duty_cycle", 1*time.Second)
|
||||
viper.SetDefault("cooler_enabled", true)
|
||||
viper.SetDefault("heater_enabled", true)
|
||||
viper.SetDefault("http.port", 8000)
|
||||
viper.SetDefault("nats.stream", "DWJONDAHL")
|
||||
viper.SetDefault("nats.subject.event", "DWJONDAHL.ingest.fermentor.ingest_event")
|
||||
|
|
Loading…
Reference in a new issue