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>
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import logging
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .coordinator import OneControlCoordinator
|
|
from .const import DOMAIN
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
PLATFORMS = [Platform.SWITCH, Platform.SENSOR, Platform.COVER]
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
address = entry.data["address"]
|
|
coordinator = OneControlCoordinator(hass, address)
|
|
try:
|
|
await coordinator.async_connect()
|
|
except Exception as e:
|
|
_LOGGER.error("Failed to connect to OneControl at %s: %s", address, e)
|
|
return False
|
|
|
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
|
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
|
return True
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
|
if unload_ok:
|
|
coordinator: OneControlCoordinator = hass.data[DOMAIN].pop(entry.entry_id)
|
|
await coordinator.async_disconnect()
|
|
return unload_ok
|