Skip to content

Commit

Permalink
Merge branch 'rebuild_integration' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdwetering committed Aug 29, 2023
2 parents 4d9a1a6 + 20ca3fc commit d6f03c6
Show file tree
Hide file tree
Showing 51 changed files with 3,438 additions and 2,752 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.11"]
steps:
- uses: "actions/checkout@v2"
- uses: "actions/checkout@v3"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
if [ -f requirements_test.txt ]; then pip install -r requirements_test.txt; fi
- name: Test with pytest
run: |
Expand All @@ -39,7 +40,7 @@ jobs:
needs: validate
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Zip custom components dir
working-directory: "custom_components"
run: zip -r huesyncbox.zip huesyncbox/*
Expand Down
123 changes: 39 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,128 +5,83 @@
Custom integration for the Philips Hue Play HDMI Sync Box.

- [About](#about)
- [Device automations](#device-automations)
- [Services](#services)
- [Known issues](#known-issues)
- [Behavior](#behavior)
- [Services](#services)
- [Updating from before version 2](#updating-from-before-version-20)
- [Installation](#installation)
- [Home Assistant Community Store (recommended)](#home-assistant-community-store-hacs)
- [Manually](#manually)
- [Debugging](#debugging)

## About

This integration exposes the Philips Hue Play HDMI Sync Box as a `media_player` in Home Assistant.
Functionality for controlling the syncbox has been mapped on existing `media_player` features for easy access (no need for custom cards).
For more info on how to control syncbox specific functionality not exposed through the standard `media_player` see the [Services](#services) section in this document.
This integration exposes the Philips Hue Play HDMI Sync Box in Home Assistant so it can be used in automations or dashboards.

The mapping is:
The Philips Hue Play HDMI Sync Box will be discovered automatically in most cases and can be added manually through the `Settings > Devices and Services` menu in Home Assistant if that is not the case.

| Mediaplayer feature | Syncbox feature |
|---|---|
| On / Off | On / Off |
| Play | Start syncing |
| Pause | Stop syncing |
| Previous / Next track | Cycle syncmodes Game, Music, Video |
| Volume | Brightness |
| Source | Source |
| Sound mode | Intensity |

Next to this some attributes have different meaning than standard `media_player` or are explicitly added for this integration.
Note that the table below _only_ mentions differences with standard `media_player`.

| Mediaplayer attribute | Description |
|---|---|
| media_title | Shows syncmode and intensity |
| media_artist | Shows selected source |
| entertainment_area | Name of currently selected entertainment areas |
| entertainment_area_list | List with names of available entertainment areas |
| hdmi#_status | Shows status of hdmi ports. Can be unplugged, plugged, linked |
| brightness | brightness setting for the box |
| intensity | intensity setting for the box, can be subtle, moderate, high, intense |
The following features are available:

## Device automations
* Power on/off
* Light sync on/off
* Intensity (subtle/moderate/high/intense)
* Sync mode (video/music/game)
* HDMI Input selection
* Brightness control
* Entertainment area selection
* HDMI1-4 connection status
* Dolby Vision compatibility on/off
* LED indicator mode
* Bridge connection status ⁺
* Bridge ID ⁺
* IP address ⁺
* Wifi quality ⁺

A lot of features are exposed in Device automation triggers, conditions and actions.
Some examples below.
Entities marked with ⁺ are default disabled.

* Triggers
* HDMI status change
* Syncing starting/stopping (a.k.a. playing/paused)
* Conditions
* HDMI has link
* Is syncing (a.k.a. playing)
* Actions
* Change brightness
* Set intensity
* Start sync in a specific mode
* Select input
### Behavior

For complete and up-to-date list create an automation and explore the options.
A few notes on behavior when changing entities.

## Services
* Enabling light sync will also power on the box
* Setting sync mode will also power on the box and start light sync on the selected mode
* When you want to change multiple entities the order is important. For example Intensity applies to the current selected mode. So if you want to change both the `intensity` and `mode` you _first_ have to change the mode and then set the intensity. Otherwise the intensity is applied to the "old" mode. If you want to avoid ordering issues you can use the `set_sync_state` service which will take care of the ordering and is more efficient.

The integration also exposes some services to control the box.
### Services

| Service name | Description |
|---|---|
| set_brightness | Set brightness |
| set_syncmode | Set syncmode |
| set_intensity | Set intensity |
| set_entertainment_area | Set entertainment area |
| set_sync_state | Control all aspects of the syncbox state. Allows setting multiple paramters at once, e.g. intensity and syncmode |
| set_bridge | Set the bridge to be used by the Philips Hue Play HDMI Syncbox. Keep in mind that changing the bridge by the box takes a while (about 15 seconds it seems). After the bridge has changed you might need to select the `entertainment_area` if connectionstate is `invalidgroup` instead of `connected`. |
The integration exposes some additional services.

For the most up-to-date list and parameter descriptions use the Services tab in the Developer tools and search for `huesyncbox` in the services list.
For the parameter descriptions use the Services tab in the Home Assistant Developer tools and search for `huesyncbox` in the services list.

## Known issues

There have been reports where Home Assistant was not able to find the Philips Hue Play HDMI Sync Box automatically.
It is unclear why it happens for some people. So far I have not been able to reproduce it which makes solving it hard.
| Service name | Description |
|---|---|
| set_bridge | Set the bridge to be used by the Philips Hue Play HDMI Syncbox. |
| set_sync_state | Set the state of multiple features of the Philips Hue Play HDMI Syncbox at once. Makes sure everything is set in the correct order and is more efficient compared to using separate commands. |

However it is now possible to add the syncbox manually through the "Add Integration" button where you can input the IP and ID of the box.
## Updating from before version 2.0

In case manual addition also does not work here are some workarounds that have been reported to work.
The 2.0 version is a complete rewrite to allow for multiple entities and modernize the integration in general, however it is a big breaking change.

* Powercycling the Philips Hue Play HDMI Sync Box and/or restart Home Assistant and give it some time (say half an hour).
* Add `huesyncbox:` to the `configuration.yaml` file as was needed for HA versions <= 0.114.0. This should not work, but it is what users report...
See the [release notes for 2.0.0](https://github.com/mvdwetering/huesyncbox/releases/tag/v2.0.0b4) for more details on the changes and migration.

No functionality is lost it just moved to a different place.

## Installation

> **Warning**
> Make sure the Philips Hue Play HDMI Sync Box has been setup with the official Hue Sync app before adding it to Home Assistant.
> **Note**
> The Wifi connection of the Philips Hue Play HDMI Sync Box has to be setup with the official Hue app before it can be added to Home Assistant.
### Home Assistant Community Store (HACS)

> **Note** This is the recommended method because you will get notified of updates.
HACS is a 3rd party downloader for Home Assistant to easily install and update custom integrations made by the community. More information and installation instructions can be found on their site https://hacs.xyz/


* Install the integration from within HACS (you can use the search box to find it)
* Restart Home Assistant
* Devices will be found automatically or can be added manually from the Home Assistant integrations screen

### Manually

> **Note**
> When not using HACS
* Install the custom component
* Download the zip from the releases section on Github
* Unzip it
* Copy it to the custom_components directory of your Home Assistnat install as usual
* Restart Home Assistant
* Devices will be found automatically or can be added manually from the Home Assistant integrations screen

## Debugging
To enable debug logging for this integration, you can control this in your Home Assistant `configuration.yaml` file.

For example :
```yaml
logger:
default: info
logs:
custom_components.huesyncbox: debug
aiohuesyncbox: debug
```
3 changes: 3 additions & 0 deletions coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
pytest --cov=custom_components/huesyncbox tests/ --cov-report term-missing --cov-report html
mypy custom_components --check-untyped-defs
Loading

0 comments on commit d6f03c6

Please sign in to comment.