Commands reverse-engineered from Bluetooth HCI snoop captures (adb bugreport) of the official Carefree Connects (BT12) Android app, confirmed across three independent captures including two isolated single-action live tests: extend/retract (feature 0x05, values 0x01/0x02 -- the device toggles motor state internally, there's no separate stop byte) and light on/off (feature 0x1a, values 0x19/0x01). Both live under GATT characteristic 02060002 on service 02060001-50e1-405f-bab0-6bb582b4d96e. Connects on demand per command (mirrors the app's own connect/act/disconnect pattern) rather than holding a persistent connection like li3_battery, since this device doesn't stream telemetry. Cover/light state is assumed/optimistic -- the notify channel (02060003) isn't decoded yet, so a diagnostic sensor just surfaces raw undecoded replies to build up data for that follow-on work. Verified end-to-end against the real device: light on/off and awning extend both worked through Home Assistant. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
"""Light platform for the Carefree BT12 awning's built-in LED strip."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from homeassistant.components.light import ColorMode, LightEntity
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant, callback
|
|
from homeassistant.helpers.entity import DeviceInfo
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import Bt12Coordinator
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
|
) -> None:
|
|
coordinator: Bt12Coordinator = hass.data[DOMAIN][entry.entry_id]
|
|
device_info = DeviceInfo(
|
|
identifiers={(DOMAIN, entry.data["address"])},
|
|
name=entry.data.get("name", "BT12 Awning"),
|
|
manufacturer="Carefree of Colorado",
|
|
model="BT12",
|
|
)
|
|
async_add_entities([Bt12Light(coordinator, device_info)])
|
|
|
|
|
|
class Bt12Light(LightEntity):
|
|
"""The awning's LED strip.
|
|
|
|
"On" always sends a fixed level byte (0x19) -- no brightness-setting
|
|
command has been decoded yet (the app's slider wasn't isolated in
|
|
reverse-engineering), so this is on/off only for now.
|
|
"""
|
|
|
|
_attr_has_entity_name = True
|
|
_attr_name = "Light"
|
|
_attr_assumed_state = True
|
|
_attr_should_poll = False
|
|
_attr_color_mode = ColorMode.ONOFF
|
|
_attr_supported_color_modes = {ColorMode.ONOFF}
|
|
|
|
def __init__(self, coordinator: Bt12Coordinator, device_info: DeviceInfo) -> None:
|
|
self._coordinator = coordinator
|
|
self._attr_unique_id = f"{coordinator.address}_light"
|
|
self._attr_device_info = device_info
|
|
|
|
@property
|
|
def is_on(self) -> bool | None:
|
|
return self._coordinator.light_on
|
|
|
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
|
await self._coordinator.async_light_on()
|
|
|
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
|
await self._coordinator.async_light_off()
|
|
|
|
async def async_added_to_hass(self) -> None:
|
|
self.async_on_remove(self._coordinator.async_add_listener(self._handle_update))
|
|
|
|
@callback
|
|
def _handle_update(self) -> None:
|
|
self.async_write_ha_state()
|