2020-02-28 08:51:28 +08:00
|
|
|
package devices
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
2020-06-09 22:03:58 +08:00
|
|
|
// TODO add thermal history graph. Update when something changes?
|
|
|
|
|
2020-02-28 08:51:28 +08:00
|
|
|
var tempUpdates []func(map[string]int) map[string]error
|
|
|
|
|
|
|
|
func RegisterTemp(update func(map[string]int) map[string]error) {
|
|
|
|
tempUpdates = append(tempUpdates, update)
|
|
|
|
}
|
|
|
|
|
|
|
|
func UpdateTemps(temps map[string]int) {
|
|
|
|
for _, f := range tempUpdates {
|
|
|
|
errs := f(temps)
|
|
|
|
if errs != nil {
|
|
|
|
for k, e := range errs {
|
2020-06-21 05:47:48 +08:00
|
|
|
log.Printf(tr.Value("error.recovfetch", "temp", k, e.Error()))
|
2020-02-28 08:51:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|