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