Repository: bramstroker/homeassistant-powercalc

Issue:
[measure] logged CT values in float in info message
That's kinda weird. Had a look at your code. I don't see how the generator could spit out floats, but somehow it does:

```
2022-06-24 13:44:41,958 [INFO] Changing light to: ColorTempVariation(bri=16, ct=233.8462)
2022-06-24 13:44:51,049 [INFO] Measured power: 0.98
2022-06-24 13:44:51,053 [INFO] Changing light to: ColorTempVariation(bri=16, ct=243.8462)
2022-06-24 13:45:00,139 [INFO] Measured power: 0.96
2022-06-24 13:45:00,139 [INFO] Changing light to: ColorTempVariation(bri=16, ct=253.8462)
2022-06-24 13:45:10,235 [INFO] Measured power: 0.95
2022-06-24 13:45:10,240 [INFO] Progress: 7%, Estimated time left: 3.0h
2022-06-24 13:45:10,240 [INFO] Changing light to: ColorTempVariation(bri=16, ct=263.8462)
2022-06-24 13:45:19,321 [INFO] Measured power: 0.96
2022-06-24 13:45:19,322 [INFO] Changing light to: ColorTempVariation(bri=16, ct=273.8462)
2022-06-24 13:45:28,409 [INFO] Measured power: 1.0
2022-06-24 13:45:28,411 [INFO] Changing light to: ColorTempVariation(bri=16, ct=283.8462)
2022-06-24 13:45:37,497 [INFO] Measured power: 0.97
2022-06-24 13:45:37,500 [INFO] Changing light to: ColorTempVariation(bri=16, ct=293.8462)
2022-06-24 13:45:46,571 [INFO] Measured power: 1.0
2022-06-24 13:45:46,573 [INFO] Changing light to: ColorTempVariation(bri=16, ct=303.8462)
2022-06-24 13:45:55,657 [INFO] Measured power: 0.98
2022-06-24 13:45:55,659 [INFO] Changing light to: ColorTempVariation(bri=16, ct=313.8462)
2022-06-24 13:46:04,755 [INFO] Measured power: 1.01
2022-06-24 13:46:04,759 [INFO] Changing light to: ColorTempVariation(bri=16, ct=323.8462)
2022-06-24 13:46:14,081 [INFO] Measured power: 1.0
2022-06-24 13:46:14,088 [INFO] Changing light to: ColorTempVariation(bri=16, ct=333.8462)
2022-06-24 13:46:23,161 [INFO] Measured power: 1.02
2022-06-24 13:46:23,162 [INFO] Changing light to: ColorTempVariation(bri=16, ct=343.8462)
2022-06-24 13:46:32,245 [INFO] Measured power: 1.0
2022-06-24 13:46:32,245 [INFO] Changing light to: ColorTempVariation(bri=16, ct=353.8462)
2022-06-24 13:46:41,339 [INFO] Measured power: 1.0
2022-06-24 13:46:41,339 [INFO] Progress: 8%, Estimated time left: 2.9h
2022-06-24 13:46:41,339 [INFO] Changing light to: ColorTempVariation(bri=16, ct=363.8462)
2022-06-24 13:46:50,415 [INFO] Measured power: 1.0
2022-06-24 13:46:50,420 [INFO] Changing light to: ColorTempVariation(bri=16, ct=370.3704)
2022-06-24 13:46:59,509 [INFO] Measured power: 0.96
2022-06-24 13:46:59,510 [INFO] Changing light to: ColorTempVariation(bri=21, ct=153.8462)
2022-06-24 13:46:59,546 [INFO] Extra waiting for significant CT change...
2022-06-24 13:47:11,595 [INFO] Measured power: 0.88
2022-06-24 13:47:11,595 [INFO] Changing light to: ColorTempVariation(bri=21, ct=163.8462)
2022-06-24 13:47:20,675 [INFO] Measured power: 0.96
2022-06-24 13:47:20,678 [INFO] Changing light to: ColorTempVariation(bri=21, ct=173.8462)
2022-06-24 13:47:29,765 [INFO] Measured power: 1.0
2022-06-24 13:47:29,769 [INFO] Changing light to: ColorTempVariation(bri=21, ct=183.8462)
2022-06-24 13:47:38,879 [INFO] Measured power: 0.96
2022-06-24 13:47:38,882 [INFO] Changing light to: ColorTempVariation(bri=21, ct=193.8462)
2022-06-24 13:47:47,967 [INFO] Measured power: 0.94
2022-06-24 13:47:47,973 [INFO] Changing light to: ColorTempVariation(bri=21, ct=203.8462)
2022-06-24 13:47:57,073 [INFO] Measured power: 0.98
2022-06-24 13:47:57,074 [INFO] Changing light to: ColorTempVariation(bri=21, ct=213.8462)
```


Discussion:
Probably the min mired value provided by HA is.

https://github.com/bramstroker/homeassistant-powercalc/blob/master/utils/measure/measure.py#L397
https://github.com/bramstroker/homeassistant-powercalc/blob/master/utils/measure/light_controller/hass.py#L38

It tries to get the minimum mired for the light from the state attributes.

Could you verify this is a float?
When this is the case we need to alter the measure script to `floor()` the min value to a full digit. and `ceil()` the max.

Resolving patch:
diff --git a/utils/measure/measure.py b/utils/measure/measure.py
--- a/utils/measure/measure.py
+++ b/utils/measure/measure.py
@@ -394,8 +394,8 @@ def get_variations(self, color_mode: str, resume_at: Optional[Variation] = None)
 
     def get_ct_variations(self) -> Iterator[ColorTempVariation]:
         """Get color_temp variations"""
-        min_mired = self.light_info.min_mired
-        max_mired = self.light_info.max_mired
+        min_mired = round(self.light_info.min_mired)
+        max_mired = round(self.light_info.max_mired)
         for bri in self.inclusive_range(MIN_BRIGHTNESS, MAX_BRIGHTNESS, CT_BRI_STEPS):
             for mired in self.inclusive_range(min_mired, max_mired, CT_MIRED_STEPS):
                 yield ColorTempVariation(bri=bri, ct=mired)


Test patch: