Skip to content

Commit 3705b0d

Browse files
authored
fix: Try REST API first for DreamView, fall back to BLE passthrough
Some devices (H6097 TV Backlight 3 Lite) work with REST but not BLE/MQTT, while others (H6199) need BLE passthrough. Try REST first and fall back to BLE on failure.
1 parent e493df4 commit 3705b0d

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

custom_components/govee/coordinator.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,7 @@ async def async_send_music_mode(
601601
return success
602602

603603
async def async_send_dreamview(self, device_id: str, enabled: bool) -> bool:
604-
"""Send DreamView command via BLE passthrough.
605-
606-
For devices where REST API DreamView toggle doesn't work (e.g., H6199),
607-
this sends a ptReal MQTT command to enable/disable DreamView mode.
604+
"""Send DreamView command via REST API, with BLE fallback.
608605
609606
Args:
610607
device_id: Device identifier.
@@ -613,18 +610,39 @@ async def async_send_dreamview(self, device_id: str, enabled: bool) -> bool:
613610
Returns:
614611
True if command was sent successfully.
615612
"""
613+
device = self._devices.get(device_id)
614+
if not device:
615+
_LOGGER.error("Unknown device for DreamView: %s", device_id)
616+
return False
617+
618+
# Try REST API first (works for HTTP-capable devices like H6097)
619+
from .models.commands import create_dreamview_command
620+
621+
try:
622+
success = await self.async_control_device(
623+
device_id, create_dreamview_command(enabled)
624+
)
625+
if success:
626+
_LOGGER.debug(
627+
"Sent DreamView %s to %s via REST API",
628+
"ON" if enabled else "OFF",
629+
device.name,
630+
)
631+
return True
632+
except ConfigEntryAuthFailed:
633+
# Let authentication errors propagate so Home Assistant can handle reauth
634+
raise
635+
except Exception as err:
636+
_LOGGER.debug("REST DreamView failed for %s: %s", device.name, err)
637+
638+
# Fall back to BLE passthrough for devices that need it
616639
if not self.mqtt_connected:
617640
_LOGGER.warning(
618641
"Cannot send DreamView for %s: MQTT not connected",
619642
device_id,
620643
)
621644
return False
622645

623-
device = self._devices.get(device_id)
624-
if not device:
625-
_LOGGER.error("Unknown device for DreamView: %s", device_id)
626-
return False
627-
628646
from .api.ble_packet import build_dreamview_packet, encode_packet_base64
629647

630648
packet = build_dreamview_packet(enabled)

0 commit comments

Comments
 (0)