|
| 1 | +--- |
| 2 | +description: Android WS Player — Home Assistant custom integration context |
| 3 | +alwaysApply: true |
| 4 | +--- |
| 5 | + |
| 6 | +# Android WS Player |
| 7 | + |
| 8 | +Home Assistant **custom integration** (HACS-ready) that exposes Android tablets as `media_player` entities. Commands are sent via the HA event bus; the tablet app listens on a WebSocket connection. |
| 9 | + |
| 10 | +- **Repo**: https://github.com/Shaffer-Softworks/Android-WS-Player |
| 11 | +- **Domain**: `android_ws_player` |
| 12 | +- **Version**: `0.2.1` (manifest) |
| 13 | +- **Min HA**: `2024.11.0` (`hacs.json`) — required for modern `OptionsFlow` |
| 14 | + |
| 15 | +## Architecture |
| 16 | + |
| 17 | +``` |
| 18 | +custom_components/android_ws_player/ |
| 19 | + __init__.py # setup_entry, reload on options change |
| 20 | + config_flow.py # user setup + options (gear icon) |
| 21 | + media_player.py # fires bus events (play_media, stop, set_volume) |
| 22 | + const.py # DOMAIN, CONF_DEVICE_ID, CONF_EVENT_TYPE |
| 23 | + strings.json + translations/en.json |
| 24 | + brand/ # custom icons (Android + headphones/play/waves); ignore brands in HACS CI |
| 25 | +``` |
| 26 | + |
| 27 | +Each config entry = one tablet. Unique ID = `device_id`. |
| 28 | + |
| 29 | +## Event contract (default type: `android_ws_player_command`) |
| 30 | + |
| 31 | +```json |
| 32 | +{ "device_id": "kitchen_tablet", "command": "play_media", "url": "...", "media_type": "music" } |
| 33 | +{ "device_id": "...", "command": "stop" } |
| 34 | +{ "device_id": "...", "command": "set_volume", "volume": 0.8 } |
| 35 | +``` |
| 36 | + |
| 37 | +## Options flow (important) |
| 38 | + |
| 39 | +HA 2024.11+ sets `self.config_entry` on `OptionsFlow` — **do not** pass `config_entry` to `__init__` or assign `self.config_entry`. Pattern: |
| 40 | + |
| 41 | +```python |
| 42 | +def async_get_options_flow(config_entry): |
| 43 | + return AndroidWsPlayerOptionsFlow() # no args |
| 44 | +``` |
| 45 | + |
| 46 | +Gear-icon 500 errors were caused by the old `__init__(config_entry)` pattern. |
| 47 | + |
| 48 | +## HACS |
| 49 | + |
| 50 | +- Root: `hacs.json`, `README.md`, `LICENSE`, `.github/workflows/validate.yaml` |
| 51 | +- CI: `hassfest` + `hacs/action` with `ignore: brands` (brand assets ship in `custom_components/.../brand/`) |
| 52 | +- GitHub repo must have **at least one topic** (e.g. `home-assistant`, `hacs-integration`) or HACS validation fails |
| 53 | +- Default store: PR to `hacs/default` → add `"Shaffer-Softworks/Android-WS-Player"` to `integration` list (alphabetical); also needs a GitHub **release** |
| 54 | + |
| 55 | +## Brand assets |
| 56 | + |
| 57 | +Custom-generated artwork (not copied from Android-Management): Android mascot + headphones + play button + sound waves. Icons: 256/512 square; logos: wide format with `@2x` variants. Source drafts may live in Cursor `assets/`; committed files are under `brand/`. |
| 58 | + |
| 59 | +## Config fields |
| 60 | + |
| 61 | +| Field | Where | Purpose | |
| 62 | +|-------|--------|---------| |
| 63 | +| `name` | entry title | Friendly name | |
| 64 | +| `device_id` | entry data | Tablet listener ID | |
| 65 | +| `event_type` | data/options | Bus event name | |
0 commit comments