Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions custom_components/myhome/sound_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ async def async_set_frequency(self, megahertz: float) -> None:
self._frequency_khz = kilohertz
self._station = None
self._attr_source = None
self._attr_media_title = None
self.async_schedule_update_ha_state()

async def async_play_media(self, media_type: str, media_id: str, **kwargs: Any) -> None:
Expand Down Expand Up @@ -326,15 +327,36 @@ async def async_play_media(self, media_type: str, media_id: str, **kwargs: Any)
@callback
def handle_event(self, message: OWNSoundEvent) -> None:
"""Apply a WHO=16 event addressed to this source device."""
dimension = getattr(message, "dimension", None)
values = [str(v) for v in (getattr(message, "dimension_value", None) or [])]
raw_dim = getattr(message, "dimension", getattr(message, "_dimension", None))
try:
dimension = int(raw_dim) if raw_dim is not None else None
except (ValueError, TypeError):
dimension = None

values = [
str(v)
for v in (
getattr(message, "dimension_value", None)
or getattr(message, "_dimension_value", None)
or getattr(message, "dimension_values", None)
or []
)
]

if dimension == 6 and values:
self._set_frequency_from_bus(values[-1])
elif dimension == 7 and values:
self._set_station_from_bus(values[-1])
elif dimension == 8 and values:
self._attr_media_title = rds_text(values)
if len(values) == 8:
self._attr_media_title = rds_text(values)
else:
LOGGER.debug(
"%s: ignoring malformed RDS frame with %d values: %s",
self.entity_id,
len(values),
values,
)
elif getattr(message, "is_on", False):
self._attr_state = MediaPlayerState.ON
elif getattr(message, "is_off", False):
Expand All @@ -354,6 +376,7 @@ def _set_frequency_from_bus(self, raw: str) -> None:
self._frequency_khz = kilohertz
self._station = None
self._attr_source = None
self._attr_media_title = None
else:
LOGGER.debug(
"%s: ignoring reported frequency %s kHz, outside the FM band",
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/traces/f500_tuner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ Authentic on-wire bus frames captured by `@manfredgittmaier-afk` on a live insta
- Seek down: `*16*5100*101##` -> locks to previous station (e.g. 88.8 MHz).
8. **RDS Blanking and Dynamic Text**:
- After tuning, tuner sends 8 spaces `*#16*101*8*32*32*32*32*32*32*32*32##` before delivering station title.
9. **Rotating RDS and Malformed Frames (`myhome_trace_MH200N_all_2026-09-26T20-00-28.json`)**:
- Reported in [PR #427 (comment 5849429368)](https://github.com/OpenWebNet-HA/MyHOME/pull/427#issuecomment-5849429368).
- Some stations rotate RDS PS text every ~5s (e.g. `*RADIO* ` / `**OOE** `).
- Rare hardware buffer glitches occasionally produce malformed 12-code frames (e.g. `*#16*101*8*42*42*79*79*69*42*79*79*69*42*42*32##`), which must be dropped to prevent state corruption.
- Live stepping sequence across presets 1–4 confirms frequency, station preset, and RDS tracking across real `OWNSoundEvent` replies.

Loading
Loading