File tree 1 file changed +19
-3
lines changed
webapp/backend/pkg/models/measurements
1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -64,11 +64,27 @@ func NewSmartFromInfluxDB(attrs map[string]interface{}) (*Smart, error) {
64
64
for key , val := range attrs {
65
65
switch key {
66
66
case "temp" :
67
- sm .Temp = val .(int64 )
67
+ temp , tempOk := val .(int64 )
68
+ if tempOk {
69
+ sm .Temp = temp
70
+ } else {
71
+ log .Printf ("unable to parse temp information: %v" , val )
72
+ }
73
+
68
74
case "power_on_hours" :
69
- sm .PowerOnHours = val .(int64 )
75
+ powerOn , powerOnOk := val .(int64 )
76
+ if powerOnOk {
77
+ sm .PowerOnHours = powerOn
78
+ } else {
79
+ log .Printf ("unable to parse power_on_hours information: %v" , val )
80
+ }
70
81
case "power_cycle_count" :
71
- sm .PowerCycleCount = val .(int64 )
82
+ powerCycle , powerCycleOk := val .(int64 )
83
+ if powerCycleOk {
84
+ sm .PowerCycleCount = powerCycle
85
+ } else {
86
+ log .Printf ("unable to parse power_cycle_count information: %v" , val )
87
+ }
72
88
default :
73
89
// this key is unknown.
74
90
if ! strings .HasPrefix (key , "attr." ) {
You can’t perform that action at this time.
0 commit comments