Add HA custom integration; fix bleak 3.x write-without-response regression
The OneControl panel's command characteristic is a streaming (Write Without Response) endpoint. Bleak 3.x changed write_gatt_char to default to write-with-response when the char advertises the "write" property, so every command (incl. switch turn_on/off) got rejected by the panel with ATT 0x0E (Unlikely Error), surfaced as BleakGATTProtocolError. Force response=False on the command write (matching the auth key write) to restore control. Also commits the productionized custom_components integration (config flow, coordinator, switch/sensor/cover entities, key-seed TEA auth, COBS codec) and the matching src/ RE client/COBS fixes (big-endian framing, table-driven CRC8, status-event decoding) that were developed but never tracked. Verified live on the campsite HAOS Pi: switch.exterior_lights / interior_lights toggle the physical panel with no GATT error. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import re
|
||||
import voluptuous as vol
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.bluetooth import async_ble_device_from_address
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .client.onecontrol_client import OneControlClient
|
||||
from .const import DOMAIN
|
||||
|
||||
_MAC_RE = re.compile(r"^([0-9A-F]{2}:){5}[0-9A-F]{2}$")
|
||||
|
||||
|
||||
class OneControlConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(self, user_input: dict | None = None) -> FlowResult:
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
if user_input is not None:
|
||||
address = user_input["address"].strip().upper()
|
||||
|
||||
if not _MAC_RE.match(address):
|
||||
errors["address"] = "invalid_mac"
|
||||
else:
|
||||
await self.async_set_unique_id(address)
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
ble_device = async_ble_device_from_address(self.hass, address)
|
||||
connected = False
|
||||
for _ in range(2):
|
||||
client = OneControlClient(address, ble_device=ble_device)
|
||||
try:
|
||||
await client.connect()
|
||||
await client.disconnect()
|
||||
connected = True
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
if not connected:
|
||||
errors["base"] = "cannot_connect"
|
||||
else:
|
||||
return self.async_create_entry(
|
||||
title=f"OneControl ({address})",
|
||||
data={"address": address},
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema({
|
||||
vol.Required("address", description={"suggested_value": "30:C6:F7:E0:80:8E"}): str,
|
||||
}),
|
||||
errors=errors,
|
||||
)
|
||||
Reference in New Issue
Block a user