Update light to handle MRS100#436
Conversation
On device MRS100 it reports as Handle Light but has no light data then digest is empty We test if digest has key light before gathering data
|
This is to correct issue #432 |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Any updates ? |
| if digest_data.has_key(light): | ||
| light_data = digest_data.get('light', []) | ||
| self._update_channel_status(channel=light_data.get('channel'), | ||
| rgb=light_data.get('rgb'), | ||
| luminance=light_data.get('luminance'), | ||
| temperature=light_data.get('temperature'), | ||
| onoff=light_data.get('onoff')) | ||
| locally_handled = True |
There was a problem hiding this comment.
| if digest_data.has_key(light): | |
| light_data = digest_data.get('light', []) | |
| self._update_channel_status(channel=light_data.get('channel'), | |
| rgb=light_data.get('rgb'), | |
| luminance=light_data.get('luminance'), | |
| temperature=light_data.get('temperature'), | |
| onoff=light_data.get('onoff')) | |
| locally_handled = True | |
| if light_data := digest_data.get('light'): | |
| self._update_channel_status(channel=light_data.get('channel'), | |
| rgb=light_data.get('rgb'), | |
| luminance=light_data.get('luminance'), | |
| temperature=light_data.get('temperature'), | |
| onoff=light_data.get('onoff')) | |
| locally_handled = True |
Sounds better 😺. Indeed, light is not a declared variable in this case, we try to check if 'light' is a key of digest_data. And the method has_key has been removed on Python 3. Also the walrus syntax allow a single lookup + binding.
The PR albertogeniola#436 line used Python 2 has_key() with an undefined `light` name, crashing on every SYSTEM_ALL update. Replace with a walrus guard that skips processing when the digest has no usable light data. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Hey! Just a note that I opened #440, which works on this same code path (light.py -> async_handle_update). Over there I also covered the case where digest.light comes back as a list (not just missing/empty). Might be worth comparing them before merging so we don't step on each other's toes. |
On device MRS100 it reports as Handle Light but has no light data then digest is empty We test if digest has key light before gathering data
Data received is :