From 588145b163d6012318f5c06edde0b318ec68ba24 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Sat, 5 Sep 2020 16:51:00 -0400 Subject: [PATCH] Update fan daemon to re-evaluate the config values if there aren't valid values for temps (ie all 0's) which causes the program to not function correct, see code comments for further details --- cmd/fan/fan.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/fan/fan.go b/cmd/fan/fan.go index 10d221f..d1993a3 100644 --- a/cmd/fan/fan.go +++ b/cmd/fan/fan.go @@ -9,8 +9,8 @@ import ( argonFan "git.sungo.io/sungo/argon/fan" - "git.kemonine.info/PiFrame/utils" "git.kemonine.info/PiFrame/config" + "git.kemonine.info/PiFrame/utils" ) const ( @@ -22,6 +22,12 @@ func main() { // Load the config file pfConfig, _ := config.LoadConfig() + // For some reason the map isn't populated 'right away' and/or doesn't always come in via koanf + // Work around by re-loading the config as necessary to get valid values + for pfConfig.Float64Map(config.CONFIG_KEY_FAN_SPEEDS)[config.CONFIG_MAP_KEY_FAN_SPEED_100] == 0 { + pfConfig, _ = config.LoadConfig() + } + // Get the various fan related config options as local variables speedMap := pfConfig.Float64Map(config.CONFIG_KEY_FAN_SPEEDS) POLL_INTERVAL := pfConfig.String(config.CONFIG_KEY_FAN_POLL_INTERVAL)