Skip to content

Update light to handle MRS100#436

Open
impulsio wants to merge 1 commit into
albertogeniola:0.4.X.Xfrom
impulsio:mrs100-lighterror
Open

Update light to handle MRS100#436
impulsio wants to merge 1 commit into
albertogeniola:0.4.X.Xfrom
impulsio:mrs100-lighterror

Conversation

@impulsio

Copy link
Copy Markdown
Contributor

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 :

Received message from topic /app/2876630-43ababbc1cc8a332cc2188f9902c6779/subscribe: b'{
	"header": {
		"messageId": "f589abcb7536a53ae15fa288dba2b3ad",
		"namespace": "Appliance.System.All",
		"triggerSrc": "Android",
		"method": "GETACK",
		"payloadVersion": 1,
		"from": "/appliance/2211013555341970080148e1e9aeb62a/publish",
		"uuid": "2211013555341970080148e1e9aeb62a",
		"timestamp": 1773903089,
		"timestampMs": 299,
		"sign": "fab44bf26f90f51b333c22b8e816a26c"
	},
	"payload": {
		"all": {
			"system": {
				"hardware": {
					"type": "mrs100",
					"subType": "un",
					"version": "7.0.0",
					"chipType": "rtl8710cm",
					"uuid": "2211013555341970080148e1e9aeb62a",
					"macAddress": "48:e1:e9:ae:b6:2a"
				},
				"firmware": {
					"version": "7.6.20",
					"homekitVersion": "6.3",
					"compileTime": "2025/12/08-18:16:09",
					"encrypt": 1,
					"wifiMac": "3a:07:16:e8:a6:00",
					"innerIp": "192.168.1.79",
					"server": "mqtt-eu-4.meross.com",
					"port": 443,
					"userId": 2876630
				},
				"time": {
					"timestamp": 1773903089,
					"timezone": "Europe/Paris",
					"timeRule": [
						[
							1679792400,
							7200,
							1
						],
						[
							1698541200,
							3600,
							0
						],
						[
							1711846800,
							7200,
							1
						],
						[
							1729990800,
							3600,
							0
						],
						[
							1743296400,
							7200,
							1
						],
						[
							1761440400,
							3600,
							0
						],
						[
							1774746000,
							7200,
							1
						],
						[
							1792890000,
							3600,
							0
						],
						[
							1806195600,
							7200,
							1
						],
						[
							1824944400,
							3600,
							0
						],
						[
							1837645200,
							7200,
							1
						],
						[
							1856394000,
							3600,
							0
						],
						[
							1869094800,
							7200,
							1
						],
						[
							1887843600,
							3600,
							0
						],
						[
							1901149200,
							7200,
							1
						],
						[
							1919293200,
							3600,
							0
						],
						[
							1932598800,
							7200,
							1
						],
						[
							1950742800,
							3600,
							0
						],
						[
							1964048400,
							7200,
							1
						],
						[
							1982797200,
							3600,
							0
						]
					]
				},
				"online": {
					"status": 1,
					"bindId": "vw44MizgGEQWwSh6",
					"who": 1
				}
			},
			"digest": {}
		}
	}
}'

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
@impulsio

Copy link
Copy Markdown
Contributor Author

This is to correct issue #432

@stale

stale Bot commented May 20, 2026

Copy link
Copy Markdown

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.

@stale stale Bot added the stale label May 20, 2026
@impulsio

Copy link
Copy Markdown
Contributor Author

Any updates ?

@stale stale Bot removed the stale label May 21, 2026
Comment on lines +61 to +68
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

GuillaumeOj added a commit to GuillaumeOj/MerossIot that referenced this pull request May 29, 2026
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>
@Araanda41

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants