mirror of
https://github.com/Luzifer/tasmota-config.git
synced 2024-12-22 18:51:21 +00:00
Improve logging and value checking
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9ac7aa8c6b
commit
514a6e2860
2 changed files with 7 additions and 3 deletions
6
main.go
6
main.go
|
@ -65,7 +65,7 @@ func main() {
|
|||
|
||||
for devName, devConfig := range config.Devices {
|
||||
if cfg.Device != "" && devName != cfg.Device {
|
||||
log.WithField("name", devName).Debug("Skipping device as requested")
|
||||
log.WithField("name", devName).Trace("Skipping device as requested")
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,6 @@ func main() {
|
|||
|
||||
func processDevice(mqttClient mqtt.Client, config *configFile, devName string, devConfig deviceConfig) error {
|
||||
log.WithField("name", devName).Info("Starting device config")
|
||||
defer log.WithField("name", devName).Info("Finished device config")
|
||||
|
||||
var (
|
||||
responses = make(chan []byte, 30)
|
||||
|
@ -129,10 +128,11 @@ func processDevice(mqttClient mqtt.Client, config *configFile, devName string, d
|
|||
|
||||
if len(updates) == 0 {
|
||||
log.WithField("name", devName).Info("Device looks good, nothing to do")
|
||||
return nil
|
||||
}
|
||||
|
||||
if cfg.DryRun {
|
||||
log.WithField("name", devName).Info("Device needs updates but requested dry-run")
|
||||
log.WithField("name", devName).Infof("Device needs %d updates but requested dry-run", len(updates))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,10 @@ func extractGenericJSONValue(setting string, payload []byte) (interface{}, error
|
|||
return nil, errors.Wrap(err, "Unable to map payload into map[string]interface{}")
|
||||
}
|
||||
|
||||
if _, ok := data[setting]; !ok {
|
||||
return nil, errors.New("Unable to find requested value")
|
||||
}
|
||||
|
||||
return data[setting], nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue