ha: add carefree_bt12 integration for the Carefree Connects awning
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>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
7911339743
commit
918003d2e3
@@ -0,0 +1,84 @@
|
||||
"""Config flow for the Carefree Connects BT12 awning integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.bluetooth import (
|
||||
BluetoothServiceInfoBleak,
|
||||
async_discovered_service_info,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
class Bt12ConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for a Carefree BT12 awning controller."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._discovery_info: BluetoothServiceInfoBleak | None = None
|
||||
self._discovered: dict[str, str] = {}
|
||||
|
||||
async def async_step_bluetooth(
|
||||
self, discovery_info: BluetoothServiceInfoBleak
|
||||
) -> FlowResult:
|
||||
"""Handle a discovered BT12 advertisement (from any Bluetooth source)."""
|
||||
await self.async_set_unique_id(discovery_info.address)
|
||||
self._abort_if_unique_id_configured()
|
||||
self._discovery_info = discovery_info
|
||||
self.context["title_placeholders"] = {"name": discovery_info.name}
|
||||
return await self.async_step_bluetooth_confirm()
|
||||
|
||||
async def async_step_bluetooth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
assert self._discovery_info is not None
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(
|
||||
title=self._discovery_info.name,
|
||||
data={
|
||||
"address": self._discovery_info.address,
|
||||
"name": self._discovery_info.name,
|
||||
},
|
||||
)
|
||||
return self.async_show_form(
|
||||
step_id="bluetooth_confirm",
|
||||
description_placeholders={"name": self._discovery_info.name},
|
||||
)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Manual entry, plus a dropdown of any BT12 already seen advertising."""
|
||||
errors: dict[str, str] = {}
|
||||
if user_input is not None:
|
||||
address = user_input["address"]
|
||||
await self.async_set_unique_id(address, raise_on_progress=False)
|
||||
self._abort_if_unique_id_configured()
|
||||
name = self._discovered.get(address, "BT12 Awning")
|
||||
return self.async_create_entry(title=name, data={"address": address, "name": name})
|
||||
|
||||
current_addresses = self._async_current_ids()
|
||||
for info in async_discovered_service_info(self.hass, connectable=True):
|
||||
if info.address in current_addresses:
|
||||
continue
|
||||
if info.name == "BT12":
|
||||
self._discovered[info.address] = info.name
|
||||
|
||||
if not self._discovered:
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema({vol.Required("address"): str}),
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema({vol.Required("address"): vol.In(self._discovered)}),
|
||||
errors=errors,
|
||||
)
|
||||
Reference in New Issue
Block a user