Skip to content

Commit

Permalink
Merge pull request #26 from parautenbach/1.4.0
Browse files Browse the repository at this point in the history
1.4.0 release
  • Loading branch information
parautenbach authored Sep 12, 2024
2 parents 3858734 + 273abd2 commit cbfbd77
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 86 deletions.
13 changes: 13 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[settings]
sections = FUTURE,STDLIB,THIRDPARTY,INBETWEENS,FIRSTPARTY,LOCALFOLDER
known_inbetweens=
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 88
ensure_newline_before_comments = True

[tool.isort]
profile = "black"

39 changes: 22 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
## v0.1.0
### New
- Initial release.
## v1.4.0
### Fixes
- Home Assistant Core deprecations
- Python 3.12 compatibility

## v1.0.3
## v1.3.1
### New
- HACS support (also thanks to [qcasey](https://github.com/qcasey)).

## v1.1.0
### Compatibility
- Support for Home Assistant 2021.12, where the MQTT publish function is now a coroutine.
- Portugese translation for config flow (thanks [ViPeR5000](https://github.com/ViPeR5000)).

## v1.1.1
### Deprecations
- Replace deprecated HA device class for media player speakers.
## v1.3.0
### Fixes
- Set the idle state when the stream ends and clear the metadata (thanks [mill1000](https://github.com/mill1000)).

## v1.2.0
### New
Expand All @@ -24,10 +21,18 @@
### Improvements
- Some technical changes regarding code structure.

## v1.3.0
### Fixes
- Set the idle state when the stream ends and clear the metadata (thanks [mill1000](https://github.com/mill1000)).
## v1.1.1
### Deprecations
- Replace deprecated HA device class for media player speakers.

## v1.3.1
## v1.1.0
### Compatibility
- Support for Home Assistant 2021.12, where the MQTT publish function is now a coroutine.

## v1.0.3
### New
- Portugese translation for config flow (thanks [ViPeR5000](https://github.com/ViPeR5000)).
- HACS support (also thanks to [qcasey](https://github.com/qcasey)).

## v0.1.0
### New
- Initial release.
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,37 @@ for [Home Assistant](https://home-assistant.io/) allows you to control and get
updates from a [Shairport Sync](https://github.com/mikebrady/shairport-sync/)
installation using [MQTT](https://mqtt.org/).

You need to compile Shairport Sync with at least the MQTT and metadata options,
for example:
You need to compile Shairport Sync with at least the MQTT and metadata options.

Example:

```
./configure --with-mqtt-client --with-metadata
```

## Installation

### Manual
### Pre-requisites

You need the Home Assistant
[MQTT integration](https://www.home-assistant.io/integrations/mqtt/) set up.

Copy the `shairport_sync` folder of this repo to
### HACS

This is the recommended way to install this integration.

It is available from the main HACS index.

### Manual

Copy the `custom_components/shairport_sync` folder of this repo to
`<config_dir>/custom_components/shairport_sync/` of your Home Assistant
installation. Create the `custom_components` directory if it doesn't exist.

### HACS
Add the repository URL as a [custom repository](https://hacs.xyz/docs/faq/custom_repositories).

## Configuration

### GUI
Click the `Add Integration` button and search for Shairport. Enter a friendly name, and the MQTT topic when prompted.
Click the `Add Integration` button and search for "Shairport". Enter a friendly name, and the MQTT topic when prompted.

### YAML
Add the following to your `configuration.yaml`'s `media_player` section
Expand All @@ -43,7 +49,7 @@ Home Assistant:
```
### Shairport Sync
Some important settings required in your `shairport-sync.conf`:
Some important settings that are required in your `shairport-sync.conf`:

```
mqtt =
Expand All @@ -60,12 +66,20 @@ mqtt =
## Compatibility
The current version of this integration has been tested against Shairport Sync 4.1 and Home Assistant Core 2023.1.7 & 2023.3.0.
The current version of this integration has been tested against Shairport Sync 3.3.7rc1 and Home Assistant Core 2024.10.0.
### Version 1.3.1
Version 1.1.1 of this integration has been tested against Shairport Sync 3.3.7rc1 and Home Assistant Core
This version has been tested against Shairport Sync 4.1 and Home Assistant Core 2023.1.7 and 2023.3.0.
### Version 1.1.1
This version has been tested against Shairport Sync 3.3.7rc1 and Home Assistant Core
2021.12.5.
Version 1.0.3 of this integration was tested against Home Assistant 0.114.1 and supported up to version 2021.11.5.
### Version 1.0.3
This version has been tested against Home Assistant 0.114.1 and supported up to version 2021.11.5.
Tested Shairport Sync details:
```
Expand Down
11 changes: 8 additions & 3 deletions custom_components/shairport_sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant


Expand All @@ -10,20 +11,24 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b

# Create platform entries
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, "media_player"))
hass.config_entries.async_forward_entry_setups(
config_entry, (Platform.MEDIA_PLAYER,)
)
)

# Reload entry when its updated
config_entry.async_on_unload(
config_entry.add_update_listener(async_reload_entry))
config_entry.async_on_unload(config_entry.add_update_listener(async_reload_entry))

return True


async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Unload a Shairport Sync device."""
await hass.config_entries.async_forward_entry_unload(config_entry, "media_player")

return True


async def async_reload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
"""Reload a Shairport Sync device."""
await hass.config_entries.async_reload(config_entry.entry_id)
44 changes: 28 additions & 16 deletions custom_components/shairport_sync/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
"""Config flow for Shairport Sync media player."""
from __future__ import annotations

from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_ID, CONF_NAME
from homeassistant.components.mqtt.const import CONF_TOPIC
from homeassistant.components.mqtt.util import valid_subscribe_topic
from homeassistant.data_entry_flow import FlowResult
from typing import Any

import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant.components.mqtt.const import CONF_TOPIC
from homeassistant.components.mqtt.util import valid_subscribe_topic
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ID, CONF_NAME

from .const import DOMAIN


class ShairportConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle config flow for Shairport Sync."""

async def async_step_user(self, user_input) -> FlowResult:
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
errors = {}
if user_input is not None:
try:
Expand All @@ -24,17 +28,17 @@ async def async_step_user(self, user_input) -> FlowResult:

# Build a "unique" ID from the MQTT topic
topic = user_input.get(CONF_TOPIC)
id = f"shairport-sync-{topic}"
uid = f"shairport-sync-{topic}"

# Set ID and fail if already configured
await self.async_set_unique_id(id)
await self.async_set_unique_id(uid)
self._abort_if_unique_id_configured()

# Build config data
data = {
CONF_ID: id,
CONF_ID: uid,
CONF_NAME: user_input.get(CONF_NAME),
CONF_TOPIC: topic
CONF_TOPIC: topic,
}

# Create a config entry with the config data
Expand All @@ -43,10 +47,18 @@ async def async_step_user(self, user_input) -> FlowResult:

user_input = user_input or {}

data_schema = vol.Schema({
vol.Required(CONF_NAME): cv.string,
vol.Required(CONF_TOPIC,
description={"suggested_value": user_input.get(CONF_TOPIC, "Shairport")}): cv.string,
})
data_schema = vol.Schema(
{
vol.Required(CONF_NAME): cv.string,
vol.Required(
CONF_TOPIC,
description={
"suggested_value": user_input.get(CONF_TOPIC, "Shairport")
},
): cv.string,
}
)

return self.async_show_form(step_id="user", data_schema=data_schema, errors=errors)
return self.async_show_form(
step_id="user", data_schema=data_schema, errors=errors
)
2 changes: 1 addition & 1 deletion custom_components/shairport_sync/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Provides the constants needed for this component."""
from homeassistant.backports.enum import StrEnum
from enum import StrEnum

DOMAIN = "shairport_sync"

Expand Down
3 changes: 2 additions & 1 deletion custom_components/shairport_sync/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"mqtt"
],
"documentation": "https://github.com/parautenbach/hass-shairport-sync/",
"integration_type": "device",
"iot_class": "local_push",
"issue_tracker": "https://github.com/parautenbach/hass-shairport-sync/issues",
"requirements": [],
"version": "1.2.0"
"version": "1.4.0"
}
Loading

0 comments on commit cbfbd77

Please sign in to comment.