fix(media_player): parse real OWNSoundEvent dimensions and handle malformed RDS frames - #497
Conversation
…formed RDS frames Resolves issue reported in PR OpenWebNet-HA#427 comment 5849429368: - Read dimension values from _dimension_value on OWNSoundEvent instances when dimension_value property is not present - Ensure tuner frequency, station, source and media_title update from incoming bus reports - Gracefully ignore malformed RDS frames with length != 8 (e.g. transient 12-code glitch frames) - Clear media_title on frequency change - Add authentic trace capture and replay test covering rotating RDS, 12-code glitch, and preset advance sequence
5ce0fcd to
8003e71
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
56bbe8f
into
OpenWebNet-HA:v2-phase1-architecture
|
Confirmed working on the MH200N + F500N – |
|
@GreenGrassBlueOcean – one more from the MH200N + F441M: volume down on the audio zones still doesn't work. Bus monitor, amplifier 41:
I know this is fixed in OWNd#49 (volume down → |
|
Yes planning on a new release. @fedem95 did a lot of great reviewing already. Waiting on his review and than we make a new ownd release |
Fixes #498.
Problem Summary
In #427 comment 5849429368, @manfredgittmaier-afk reported that on a live installation (MH200N + F500N tuner, OWNd 2.0.0b8), tuner command transmission worked (station select and next/previous stepped the tuner), but incoming reports (
frequency,station,source, andmedia_title) never updated the entity:*16*6001*101##), the bus replied with dimension frames 6, 7, and 8 (*#16*101*6*0*103500##,*#16*101*7*0*4##,*#16*101*8*65*78*84*69*78*78*69*32##), but the entity remained on stale state.*RADIO*/**OOE**), and transient hardware glitches occasionally emit malformed dimension 8 frames with 12 ASCII codes instead of 8 (e.g.*#16*101*8*42*42*79*79*69*42*79*79*69*42*42*32##).Root Cause Analysis
OWNSoundEventdimension values attribute mismatch:In
OWNd.message.OWNSoundEvent, dimension payload parameters are stored in the instance attribute_dimension_value(e.g.['0', '103500']), whileOWNddoes not expose a publicdimension_valueproperty.In
custom_components/myhome/sound_source.py,handle_eventevaluatedgetattr(message, "dimension_value", None) or [], which always returned[]on realOWNSoundEventinstances. Becausevalueswas empty, all dimension branches (6, 7, and 8) were skipped. In unit tests, mocks had manually setdimension_value=..., masking the mismatch.Transient hardware buffer glitches occasionally emitted dimension 8 frames containing 12 ASCII codes instead of the standard 8 codes.
Tuning away to a new frequency should clear any stale
media_titlefrom the previous station until new RDS arrives.Changes
custom_components/myhome/sound_source.py:dimension_value,_dimension_value, anddimension_values.dimensionto integer.len(values) == 8; log and ignore malformed frames with length != 8 to prevent title corruption or blanking._attr_media_title = Nonewhen frequency changes in_set_frequency_from_busandasync_set_frequency.myhome_trace_MH200N_all_2026-09-26T20-00-28.jsoncontributed by @manfredgittmaier-afk undertests/fixtures/traces/f500_tuner/.tests/test_sound_source_trace_replay.pyto instantiate realOWNSoundEventobjects directly from raw bus frames.test_f500n_station_advance_and_rds_rotation_replayreplaying the full trace and verifying rotating RDS, 12-code glitch rejection, and station advance across presets 1–4.tests/test_component_sound_source.pyfor realOWNSoundEventhandling, malformed RDS rejection, and source following after next/previous.Verification
ruff checkandscripts/verify_ha_standards.pyclean with 0 violations.