Skip to content

Commit d8f230c

Browse files
author
Tom Lasswell
committed
feat: Add per-device transport diagnostics (Cloud API / MQTT / BLE)
Every Govee device entity now exposes three transport diagnostic attributes visible in the HA entity details UI: - transport_cloud_api: always True (REST API is the baseline) - transport_mqtt: True when AWS IoT MQTT push is connected - transport_ble: True when a local Bluetooth connection is active These show up as state attributes on every light, fan, switch, sensor, select, and button entity — no separate diagnostic sensor needed. Also adds a per-device "transport" block to the diagnostics download (Settings → Devices → Govee → Download diagnostics) so troubleshooting reports include which transports each device is using. Changes: - entity.py: extra_state_attributes property on GoveeEntity base class - coordinator.py: is_ble_available(device_id) public method - diagnostics.py: per-device transport block in diagnostic dump
1 parent ebf9595 commit d8f230c

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

custom_components/govee/coordinator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ def mqtt_connected(self) -> bool:
224224
"""Return True if MQTT client is connected."""
225225
return self._mqtt_client is not None and self._mqtt_client.connected
226226

227+
def is_ble_available(self, device_id: str) -> bool:
228+
"""Return True if a BLE transport is active for this device."""
229+
return device_id in self._ble_devices
230+
227231
@property
228232
def states(self) -> dict[str, GoveeDeviceState]:
229233
"""Get current states for all devices."""

custom_components/govee/diagnostics.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ async def async_get_config_entry_diagnostics(
6161
"color_temp_kelvin": state.color_temp_kelvin if state else None,
6262
"source": state.source if state else None,
6363
},
64+
"transport": {
65+
"cloud_api": True,
66+
"mqtt": coordinator.mqtt_connected,
67+
"ble": coordinator.is_ble_available(device_id),
68+
},
6469
}
6570

6671
# Collect MQTT status

custom_components/govee/entity.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
- Device info
55
- Coordinator integration
66
- State updates
7+
- Transport diagnostics (Cloud API / MQTT / BLE)
78
"""
89

910
from __future__ import annotations
1011

11-
from typing import TYPE_CHECKING
12+
from typing import TYPE_CHECKING, Any
1213

1314
from homeassistant.helpers.device_registry import DeviceInfo
1415
from homeassistant.helpers.update_coordinator import CoordinatorEntity
@@ -85,6 +86,21 @@ def device_state(self) -> GoveeDeviceState | None:
8586
"""Get current device state from coordinator."""
8687
return self.coordinator.get_state(self._device_id)
8788

89+
@property
90+
def extra_state_attributes(self) -> dict[str, Any]:
91+
"""Return transport protocol diagnostics for this device.
92+
93+
Shows which communication channels are active:
94+
- cloud_api: always True (REST API is the baseline transport)
95+
- mqtt: True when AWS IoT MQTT push is connected
96+
- ble: True when a local Bluetooth connection is available
97+
"""
98+
return {
99+
"transport_cloud_api": True,
100+
"transport_mqtt": self.coordinator.mqtt_connected,
101+
"transport_ble": self.coordinator.is_ble_available(self._device_id),
102+
}
103+
88104
@staticmethod
89105
def _infer_area_from_name(name: str) -> str | None:
90106
"""Infer area from device name.

0 commit comments

Comments
 (0)