Skip to content

Commit f6a3f5a

Browse files
authored
Merge pull request #1 from Shaffer-Softworks/hacs
Initial commit of Android WS Player integration for Home Assistant, i…
2 parents 863b920 + 2ad693c commit f6a3f5a

19 files changed

Lines changed: 294 additions & 8 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 |

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @Shaffer-Softworks

.github/workflows/validate.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Validate
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
schedule:
12+
- cron: "0 0 * * *"
13+
14+
permissions: {}
15+
16+
jobs:
17+
hassfest:
18+
name: Hassfest validation
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout the repository
22+
uses: actions/checkout@v6
23+
24+
- name: Run hassfest validation
25+
uses: home-assistant/actions/hassfest@master
26+
27+
hacs:
28+
name: HACS validation
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout the repository
32+
uses: actions/checkout@v6
33+
34+
- name: Run HACS validation
35+
uses: hacs/action@main
36+
with:
37+
category: integration
38+
# Custom integrations ship brand assets in-repo (HA 2026.3+).
39+
ignore: brands

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
.env
8+
.venv/
9+
venv/
10+
11+
# IDE / OS
12+
.idea/
13+
.vscode/
14+
.DS_Store
15+
*.swp
16+
17+
# Home Assistant dev
18+
.storage/
19+
.homeassistant/
20+
config/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Shaffer-Softworks
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Android WS Player
2+
3+
[![hacs_badge](https://img.shields.io/badge/HACS-Custom-41BDF5.svg)](https://github.com/hacs/integration)
4+
[![Validate](https://github.com/Shaffer-Softworks/Android-WS-Player/actions/workflows/validate.yaml/badge.svg)](https://github.com/Shaffer-Softworks/Android-WS-Player/actions/workflows/validate.yaml)
5+
6+
Home Assistant custom integration that exposes each Android tablet as a **media player** entity. Play, stop, and volume commands are delivered to your tablet app as Home Assistant bus events.
7+
8+
## Features
9+
10+
- One media player entity per tablet
11+
- Configurable `device_id` and event type per device
12+
- Rename devices from the integration options (gear icon)
13+
- `play_media`, `stop`, and `volume_set` support
14+
15+
## Installation
16+
17+
### HACS (recommended)
18+
19+
1. Install [HACS](https://hacs.xyz/docs/setup/download) if you have not already.
20+
2. Open **HACS → Integrations → ⋮ → Custom repositories**.
21+
3. Add `https://github.com/Shaffer-Softworks/Android-WS-Player` as category **Integration**, then search for **Android WS Player** and install.
22+
4. Restart Home Assistant.
23+
5. Go to **Settings → Devices & services → Add integration** and choose **Android WS Player**.
24+
25+
If this repository is listed in the [HACS default store](https://github.com/hacs/default), you can install it directly without adding a custom repository.
26+
27+
### Manual
28+
29+
1. Copy `custom_components/android_ws_player` into your Home Assistant `config/custom_components/` directory.
30+
2. Restart Home Assistant.
31+
3. Add the integration from **Settings → Devices & services**.
32+
33+
## Configuration
34+
35+
During setup you provide:
36+
37+
| Field | Description |
38+
| --- | --- |
39+
| **Name** | Friendly name shown in Home Assistant (e.g. `Kitchen Tablet`) |
40+
| **Device ID** | Identifier your Android app listens for (e.g. `kitchen_tablet`) |
41+
| **Event type** | HA event name fired for commands (default: `android_ws_player_command`) |
42+
43+
Use the integration **gear icon** to change the name or event type later.
44+
45+
## Android app
46+
47+
Your tablet app should subscribe to the configured event type on the Home Assistant WebSocket API. Each event payload includes:
48+
49+
| Field | Description |
50+
| --- | --- |
51+
| `device_id` | Matches the ID configured in Home Assistant |
52+
| `command` | `play_media`, `stop`, or `set_volume` |
53+
| `url` | Media URL (for `play_media`) |
54+
| `volume` | Level 0.0–1.0 (for `set_volume`) |
55+
56+
Example `play_media` event:
57+
58+
```json
59+
{
60+
"device_id": "kitchen_tablet",
61+
"command": "play_media",
62+
"url": "https://example.com/stream.mp3",
63+
"media_type": "music"
64+
}
65+
```
66+
67+
## Development
68+
69+
Validation runs on every push via GitHub Actions (`hassfest` + HACS). Brand images are bundled under `custom_components/android_ws_player/brand/` for Home Assistant 2026.3+.
70+
71+
## Support
72+
73+
- [Open an issue](https://github.com/Shaffer-Softworks/Android-WS-Player/issues)
74+
75+
## License
76+
77+
MIT — see [LICENSE](LICENSE).
67.7 KB
Loading
256 KB
Loading
10 KB
Loading
40.4 KB
Loading

0 commit comments

Comments
 (0)