Conversation
|
So it only happens occasionally, and it happens because abode is rounding or sending a value 1 off from the value we're sending? I remember writing some code that was converting 0-255 to 0-100, so it's not because HASS is rounding incorrectly/differently? |
|
That was on the Home Assistant side where HA sends a brightness value of 0-255 which needs to be converted to a value of 0-99 (not 100), source code here. The issue was Abode would reject a brightness value of 100 for whatever reason. This “issue” is with the hue value. When we send a hue value, the response from that request will sometimes come back with a value that is off by 1 from what we sent, which triggers the warning log message. My only guess is Abode is doing some sort of conversion of the value on their end and it gets converted back for the response message which results in a rounding error in some cases. I knew about this when adding the support for changing colors, but just accepted it at the time. At first I was thinking we should suppress the log message but I think this solution is better - if it’s performing as expected, don’t log. |
|
Cool seems good to me! |
When changing the color of a light, Abode will sometimes return a hue value that is off by 1 resulting in a warning log message, "Set color mismatch for device...". In an attempt to reduce unnecessary logging messages (mostly to reduce extraneous logging messages in Home Assistant), this pull request makes a slight modification to the comparison of the requested and response object hue value using the math standard library. The
isclosemethod (added in Python 3.5) is used withabs_tolset to1. This way, if the values are ever anything greater than 1.0, the warning log message will appear, which shouldn't happen unless something is really off. If the values are equal to or less than 1.0, the warning log message will not appear. I've only seen this "issue" with the hue value, hence the reason I only made the change there.Edit: Just spent more time than I'd like to admit on confusion with the
oroperator. The parenthesis around the entireifstatement led me down the wrong path, then trying to format the code so the line wasn't too long confused me even more. It should be correct now.math.isclose(response_object["hue"], int(hue), abs_tol=1)will returnTrueif the difference between the hue values are less than or equal to 1.So basically my logic is, if not true (i.e. the difference between the hue values are greater than 1) or the saturation values don't match, then log the warning. Clear as mud.... I need some sleep.