Skip to content

Commit 9ea7225

Browse files
author
NOisi-X
committed
fix(zeo): correct voice DP read/write semantics per bundle
VoiceVolume (10009) and VoiceSwitch (10301) are read-write: they have getters (voiceVolume / isVoiceSwitchOn) and appear in the bundle's loadFeatureDps query list (gated by FeatureBit.VoiceAssistant). Add their _try_json converters to the read-write protocol entries so query_values() returns parsed JSON. SetSoundPackage (10003) and VoiceRecordDelete (10304) are write-only (no getter, not in any query list) - remove their dead converters. Rename module-level __init__ to __all__ (former was a bug that overshadowed the module's __init__ attribute).
1 parent 21d535a commit 9ea7225

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎roborock/devices/traits/a01/__init__.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
_LOGGER = logging.getLogger(__name__)
9191

92-
__init__ = [
92+
__all__ = [
9393
"DyadApi",
9494
"ZeoApi",
9595
"ZeoCommandTrait",
@@ -139,7 +139,9 @@ def _try_json(val: Any) -> Any:
139139
try:
140140
return json.loads(val)
141141
except ValueError:
142-
pass
142+
_LOGGER.debug(
143+
"Failed to parse JSON for value %r, returning as-is", val
144+
)
143145
return val
144146

145147

@@ -207,18 +209,16 @@ def _try_json(val: Any) -> Any:
207209
RoborockZeoProtocol.DETERGENT_SET: lambda val: bool(val),
208210
RoborockZeoProtocol.SOFTENER_SET: lambda val: bool(val),
209211
RoborockZeoProtocol.FLUFF_CLEANED: lambda val: bool(val),
212+
# read-write (JSON objects — bundle reads via JSON.parse)
213+
RoborockZeoProtocol.VOICE_VOLUME: lambda val: _try_json(val), # {"snd_volume": int}
214+
RoborockZeoProtocol.VOICE_SWITCH: lambda val: _try_json(val), # {"speech_switch": 1/0}
210215
# read-write (int-valued)
211216
RoborockZeoProtocol.CUSTOM_PARAM_SAVE: lambda val: int(val),
212217
RoborockZeoProtocol.CUSTOM_PARAM_GET: lambda val: int(val),
213218
RoborockZeoProtocol.DEFAULT_SETTING: lambda val: bool(val),
214219
# NOTE: LIGHT_SETTING(229) / DETERGENT_VOLUME(230) / SOFTENER_VOLUME(231)
215220
# are "server schema only" and do NOT exist in the device bundle — they
216221
# have no device-side implementation, so no converters are registered.
217-
# meta — write-only (JSON payloads; echo back as JSON strings)
218-
RoborockZeoProtocol.SET_SOUND_PACKAGE: lambda val: _try_json(val),
219-
RoborockZeoProtocol.VOICE_VOLUME: lambda val: _try_json(val),
220-
RoborockZeoProtocol.VOICE_SWITCH: lambda val: _try_json(val),
221-
RoborockZeoProtocol.VOICE_RECORD_DELETE: lambda val: _try_json(val),
222222
}
223223

224224

‎roborock/roborock_message.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ class RoborockZeoProtocol(RoborockEnum):
213213
PRIVACY_INFO = 10006 # wo
214214
OTA_NFO = 10007 # ro forceLoad only
215215
WASHING_LOG = 10008 # ro forceLoad only, JSON
216-
VOICE_VOLUME = 10009 # wo [independent] setVoiceVolume(int) → JSON.stringify({snd_volume: int})
216+
VOICE_VOLUME = 10009 # rw [independent] setVoiceVolume(int) → JSON.stringify({snd_volume: int}); readable via voiceVolume getter (FeatureBit.VoiceAssistant gated)
217217
RPC_REQUEST = 10101 # wo rpcRequest(method) → JSON
218218
RPC_RESPONSE = 10102 # -- MQTT push protocol 102, not a device DP
219-
VOICE_SWITCH = 10301 # wo [independent] setVoiceSwitchStatus(bool) → JSON.stringify({speech_switch: 1/0})
219+
VOICE_SWITCH = 10301 # rw [independent] setVoiceSwitchStatus(bool) → JSON.stringify({speech_switch: 1/0}); readable via isVoiceSwitchOn getter (FeatureBit.VoiceAssistant gated)
220220
VOICE_RECORD_INFO = 10302 # ro cache-derived, auto JSON decoded
221221
VOICE_RECORD = 10303 # ro query via getVoiceControlRecord(), JSON {result:{history:[{id,ts,...}]}}
222222
VOICE_RECORD_DELETE = 10304 # wo [independent] deleteVoiceControlRecord(id) → JSON.stringify({dialog_delete: id})

0 commit comments

Comments
 (0)