An open API service indexing awesome lists of open source software.

https://github.com/thingspanel/thingspanel-device-connector-homeassistant

ThingsPanel Home Assistant DeviceConnector
https://github.com/thingspanel/thingspanel-device-connector-homeassistant

Last synced: 20 days ago
JSON representation

ThingsPanel Home Assistant DeviceConnector

Awesome Lists containing this project

README

          

# Home Assistant DeviceConnector

ThingsPanel `DeviceConnector` for Home Assistant. This is the new connector runtime implementation. The local directory keeps the historical `homeassistant-service` name, but the standalone repository should be `thingspanel-device-connector-homeassistant`.

## Publish identity

- `connectorKey`: `homeassistant`
- Standalone repo: `github.com/thingspanel/thingspanel-device-connector-homeassistant`
- Suggested visibility: public

## Scope

- Discover Home Assistant entities through the HA REST API
- Control standard switch/light style entities through the internal MQTT command bridge
- Periodically publish state/telemetry back to ThingsPanel
- Keep Home Assistant and Xiaomi connectors separated: HA manages entities inside Home Assistant, while `xiaomi` talks to Xiaomi cloud/LAN directly

## Runtime configuration

Required environment variables:

- `CONNECTOR_SERVICE_IDENTIFIER=homeassistant`
- `CONNECTOR_INSTANCE_ID=`
- `THINGSPANEL_BACKEND_URL=http://127.0.0.1:4000`
- `HA_BASE_URL=http://127.0.0.1:8123`
- `HA_ACCESS_TOKEN=`

MQTT bridge and telemetry:

- `TP_MQTT_BROKER=tcp://127.0.0.1:1883`
- `HA_TP_DEVICE_ID=`
- `HA_MQTT_USERNAME=`
- `HA_MQTT_PASSWORD=`
- `HA_ENTITY_ID=`
- `HA_TELEMETRY_INTERVAL_SECONDS=30`

## Local run

```bash
cd examples/device-connectors/homeassistant-service
go run .
curl http://127.0.0.1:9001/health
curl "http://127.0.0.1:9001/api/v1/form/config?form_type=SVCR"
```

## Standard commands

Topic:

```text
plugin/homeassistant/devices/command//
```

Examples:

- `{"method":"switch","params":"on"}`
- `{"method":"switch","params":"off"}`
- `{"method":"brightness","params":35}`
- `{"method":"query","params":"state"}`

Local helper:

```bash
go run ./cmd/publish-command -service homeassistant -method query -params '"state"'
```

## Verification and deploy

```bash
go test ./...
```

Deploy helper in this monorepo:

```bash
cd encore-api
go run ./cmd/deploy-homeassistant-service
```