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

Fix brightness / white_temperature

brightness and white_temperature are sometimes binded to Float64 (don't
ask why). So I used convertToInt()
parent 9db5b1d7
No related branches found
No related tags found
No related merge requests found
......@@ -297,10 +297,10 @@ func (dev *Lamp) update(payload map[string]interface{}) {
}
// brightness
brightness, exists := payload["brightness"].(int)
if exists {
brightness = brightness / 255 * 100
dev.GetAttribute("brightness").SetValue(brightness)
brightness, err := convertToInt(payload["brightness"])
if err == nil {
brightness = brightness * 100 / 255
dev.GetAttribute("brightness").SetValue(int(brightness))
}
// color_temp
......@@ -308,10 +308,9 @@ func (dev *Lamp) update(payload map[string]interface{}) {
// color_temp change when we are in color mode (looks like a z2m bug)
// so we have to only update when we are in white mode. Without this check
// the color_temp is wrong when you change the mode w/ setMode
color_temp, exists := payload["color_temp"].(int)
if exists {
color_temp = convertMired(color_temp)
dev.GetAttribute("white_temperature").SetValue(color_temp)
color_temp, err := convertToInt(payload["color_temp"])
if err == nil {
dev.GetAttribute("white_temperature").SetValue(convertMired(color_temp))
}
}
......
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