Detect: improve debug output and reduce number of lines (#1022)
This commit is contained in:
parent
9828f95ba2
commit
2c4a3f6c20
3 changed files with 19 additions and 18 deletions
|
|
@ -1,8 +1,6 @@
|
|||
package detect
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/andig/evcc/detect/tasks"
|
||||
)
|
||||
|
||||
|
|
@ -44,21 +42,23 @@ const (
|
|||
)
|
||||
|
||||
func init() {
|
||||
taskList.Add(tasks.Task{
|
||||
ID: taskSMA,
|
||||
Type: tasks.Sma,
|
||||
})
|
||||
|
||||
taskList.Add(tasks.Task{
|
||||
ID: taskKEBA,
|
||||
Type: tasks.Keba,
|
||||
})
|
||||
|
||||
taskList.Add(tasks.Task{
|
||||
ID: TaskPing,
|
||||
Type: tasks.Ping,
|
||||
})
|
||||
|
||||
taskList.Add(tasks.Task{
|
||||
ID: taskSMA,
|
||||
Type: tasks.Sma,
|
||||
Depends: TaskPing,
|
||||
})
|
||||
|
||||
taskList.Add(tasks.Task{
|
||||
ID: taskKEBA,
|
||||
Type: tasks.Keba,
|
||||
Depends: TaskPing,
|
||||
})
|
||||
|
||||
taskList.Add(tasks.Task{
|
||||
ID: TaskModbus,
|
||||
Type: tasks.Tcp,
|
||||
|
|
@ -273,8 +273,8 @@ func init() {
|
|||
Type: tasks.Http,
|
||||
Depends: TaskHttp,
|
||||
Config: map[string]interface{}{
|
||||
"path": "/middleware.php/entity.json",
|
||||
"timeout": 500 * time.Millisecond,
|
||||
"path": "/middleware.php/entity.json",
|
||||
"jq": ".version",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,8 +90,6 @@ func (l *TaskList) Test(log *util.Logger, id string, input tasks.ResultDetails)
|
|||
if id == "" {
|
||||
inputs = append(inputs, input)
|
||||
} else {
|
||||
log.DEBUG.Printf("ip: %s task: %s (%v)", input.IP, id, input)
|
||||
|
||||
var task tasks.Task
|
||||
for _, t := range l.tasks {
|
||||
if t.ID == id {
|
||||
|
|
@ -101,6 +99,9 @@ func (l *TaskList) Test(log *util.Logger, id string, input tasks.ResultDetails)
|
|||
}
|
||||
|
||||
inputs = task.Test(log, input)
|
||||
success := len(inputs) > 0
|
||||
log.DEBUG.Printf("task: %s %v -> %v", id, input, success)
|
||||
|
||||
for _, detail := range inputs {
|
||||
all = append(all, tasks.Result{
|
||||
Task: task,
|
||||
|
|
|
|||
|
|
@ -199,10 +199,10 @@ func (h *ModbusHandler) Test(log *util.Logger, in ResultDetails) (res []ResultDe
|
|||
|
||||
var ok bool
|
||||
if h.op.OpCode > 0 {
|
||||
log.DEBUG.Printf("slave id: %d op: %v", slaveID, h.op)
|
||||
// log.DEBUG.Printf("slave id: %d op: %v", slaveID, h.op)
|
||||
ok = h.testRegister(log, conn.ModbusClient())
|
||||
} else {
|
||||
log.DEBUG.Printf("slave id: %d models: %v", slaveID, h.Models)
|
||||
// log.DEBUG.Printf("slave id: %d models: %v", slaveID, h.Models)
|
||||
ok = h.testSunSpec(log, conn, dev, &mr)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue