diff --git a/xaal.go b/xaal.go
index 6aebc587d25c368e1a65522f4f7f865672b06b00..d5e770c019f18ac38f175960471aeb9218a5b06c 100644
--- a/xaal.go
+++ b/xaal.go
@@ -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))
 		}
 	}