Skip to content
Snippets Groups Projects
Commit 77a43235 authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Cleanup Link

parent 6067145c
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,6 @@ package main ...@@ -3,7 +3,6 @@ package main
import ( import (
"fmt" "fmt"
"log/slog" "log/slog"
"math"
"github.com/lucasb-eyer/go-colorful" "github.com/lucasb-eyer/go-colorful"
"gitlab.imt-atlantique.fr/xaal/code/go/core/schemas" "gitlab.imt-atlantique.fr/xaal/code/go/core/schemas"
...@@ -125,6 +124,7 @@ func (dev *Hygrometer) update(payload map[string]interface{}) { ...@@ -125,6 +124,7 @@ func (dev *Hygrometer) update(payload map[string]interface{}) {
// ============================================================================= // =============================================================================
func NewLinkQuality(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInterface { func NewLinkQuality(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInterface {
dev := &LinkQuality{XAALDevice{schemas.NewLinkquality(addr), zDev, exp}} dev := &LinkQuality{XAALDevice{schemas.NewLinkquality(addr), zDev, exp}}
dev.GetAttribute("level").Value = 0 // override type to int
dev.setup() dev.setup()
dev.RemoveAttribute("devices") dev.RemoveAttribute("devices")
dev.UnsupportedAttributes = []string{"devices"} dev.UnsupportedAttributes = []string{"devices"}
...@@ -132,9 +132,9 @@ func NewLinkQuality(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInte ...@@ -132,9 +132,9 @@ func NewLinkQuality(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInte
} }
func (dev *LinkQuality) update(payload map[string]interface{}) { func (dev *LinkQuality) update(payload map[string]interface{}) {
value, exists := payload[dev.Expose.Name].(float64) value, err := convertToInt(payload[dev.Expose.Name])
if exists { if err == nil {
value = math.Round(value / 255 * 100) value = value * 100 / 255
dev.GetAttribute("level").SetValue(value) dev.GetAttribute("level").SetValue(value)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment