Conversation
Fix light sensor detection on models which return LigSen = 0.
|
Looking for people who can test this one (I don't have this feature) |
|
Thanks for tracking this down. The root cause analysis is correct. I confirmed the mechanism on my own unit. return result["dat"][0] if len(result["dat"]) == 1 else result["dat"]So I don't want to merge Measured on my test unit:
So on a model that does not know About the evidence: I do not have a unit that lacks One extra clause separates the two cases: # An unsupported property comes back as an empty dat list. A supported one
# returns its value, which can legitimately be 0.
if light_sensor is not None and light_sensor != []:I tested this against the component with a local fake device, in three cases: sensor present reporting One more thing: On branches: this fix belongs on |
|
Hi @RobHofmann |
|
@fstancu Yes, agreed, that is cleaner. Returning Two things to add. The same fix is needed at all five detection sites, not just the light sensor. dat = result["dat"]
if not dat:
return None
return dat[0] if len(dat) == 1 else datplus Digging further, the index-based mapping is the actual root cause. I measured this on my test unit. When a requested property is unknown, the device drops it from both
This is the failure I predicted in my earlier comment. It is now measured, not predicted. The device already tells us which properties it answered. Keying on values = dict(zip(result["cols"], result["dat"]))Feature detection then becomes "is the property in My suggestion: keep this PR to the minimal On 4.0.5: correct, the fix is not in it. This PR is still open, so no release contains it yet. |
Fix light sensor detection on models which return LigSen = 0.