Skip to content

Commit

Permalink
New client, 100% volume fix (#10)
Browse files Browse the repository at this point in the history
- New HTD MC client.
- #5 - volume fix
  • Loading branch information
hikirsch authored Jul 12, 2024
1 parent 4aab899 commit 465d6b4
Show file tree
Hide file tree
Showing 13 changed files with 641 additions and 279 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.2.0 - TBD
- Upgrading to HASS 2026.6.4
- New client. Better support for volume changes and bass, treble and balance. ([#5](https://github.com/hikirsch/htd_mc-home-assistant/issues/5)).

### 1.1.0 - March 31, 2024
- Upgrading to support HASS 2024.1.0 ([#7](https://github.com/hikirsch/htd_mc-home-assistant/issues/7)).
- Adding support for HACS
Expand Down
Binary file added HTD MCA-66 Hex Codes.pdf
Binary file not shown.
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
# HTD MC/MCA-66 Series Integration for Home Assistant

This integration will add the HTD MC/MCA-66 Whole House Audio into Home Assistant. This integration depends on
This integration will add the HTD MC/MCA-66 Whole House Audio into Home
Assistant. This integration depends on

## Installation steps

### Via HACS (Home Assistant Community Store)

Easiest install is via [HACS](https://hacs.xyz/):
Easiest installation is via [HACS](https://hacs.xyz/):

[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=hikirsch&repository=htd_mc-home-assistant&category=integration)

`HACS -> Integrations -> Explore & Add Repositories -> HTD MC/MCA-66 Series`

### Manually
Download the 4 files (`__init__.py`, `htd_mc.py`, `media_player.py`, `manifest.json`) from this repo and place them into your `custom_components/htd_mc` folder.

Download the 4 files (`__init__.py`, `htd_mc.py`, `media_player.py`,
`manifest.json`) from this repo and place them into your
`custom_components/htd_mc` folder.

### Configure

Update your configuration.yaml with at minimally the host.

```yaml
htd_mc:
- host: 192.168.1.123
Expand All @@ -30,16 +36,23 @@ Update your configuration.yaml with at minimally the host.
- FM/AM
- host: 192.168.xxx.xxx
```
### Configuration options
| Name | Default Value | Description |
|---------|---------------|--------------------------------------------------|
| host | (none) | IP address/host of the gateway |
| port | 10006 | Port number |
| zones | Zone X | A list of named zones |
| sources | Source X | A list of named sources |
| Name | Default Value | Description |
|-------------------------|---------------|---------------------------------------------------------------------------|
| host | (none) | IP address/host of the gateway |
| port | 10006 | Port number |
| zones | Zone X | A list of named zones |
| sources | Source X | A list of named sources |
| update_volume_on_change | false | Show tick updates on volume change |
| retry_attempts | 5 | how many times to try and re-run the command if it fails |
| socket_timeout | 1 | How long, in seconds, the client should wait before timing out. |
| command_delay | 100 | How long, in milliseconds, should the client throttle inbetween commands. |
## Code Credits
- https://github.com/whitingj/mca66
- https://github.com/steve28/mca66
- http://www.brandonclaps.com/?p=173
- https://github.com/lounsbrough/htd-mca-66-api
82 changes: 62 additions & 20 deletions custom_components/htd_mc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,62 @@
"""Support for Home Theatre Direct's MC series"""
import voluptuous as vol

from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, discovery
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_PASSWORD, CONF_USERNAME
import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery
from homeassistant.helpers.typing import ConfigType

from .htd_mc import DEFAULT_HTD_MC_PORT, HtdMcClient
from .htd_mc_client.client import HtdMcClient
from .htd_mc_client.constants import HtdConstants

DOMAIN = "htd_mc"

CONF_ZONES = "zones"
CONF_SOURCES = "sources"
CONF_RETRY_ATTEMPTS = "retry_attempts"
CONF_SOCKET_TIMEOUT = "socket_timeout"
CONF_COMMAND_DELAY = "command_delay"
CONF_UPDATE_VOLUME_ON_CHANGE = "update_volume_on_change"

CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.Schema(
[{
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_HTD_MC_PORT): cv.port,
vol.Optional(CONF_ZONES): vol.All(
cv.ensure_list, [cv.string]
),
vol.Optional(CONF_SOURCES): vol.All(
cv.ensure_list, [cv.string]
),
}]
[
{
vol.Required(CONF_HOST): cv.string,
vol.Optional(
CONF_PORT, default=HtdConstants.DEFAULT_HTD_MC_PORT
): cv.port,
vol.Optional(CONF_ZONES): vol.All(
cv.ensure_list,
[cv.string]
),
vol.Optional(CONF_SOURCES): vol.All(
cv.ensure_list,
[cv.string]
),
vol.Optional(
CONF_RETRY_ATTEMPTS,
default=HtdConstants.DEFAULT_RETRY_ATTEMPTS
): cv.port,
vol.Optional(
CONF_SOCKET_TIMEOUT,
default=HtdConstants.DEFAULT_SOCKET_TIMEOUT
): cv.port,
vol.Optional(
CONF_COMMAND_DELAY,
default=HtdConstants.DEFAULT_COMMAND_DELAY
): cv.port,
vol.Optional(CONF_UPDATE_VOLUME_ON_CHANGE): cv.boolean,
}
]
)
},
extra=vol.ALLOW_EXTRA,
)


def setup(hass: HomeAssistant, config: ConfigType):
htd_config = config.get(DOMAIN)

Expand All @@ -43,6 +68,12 @@ def setup(hass: HomeAssistant, config: ConfigType):
port = htd_item_config.get(CONF_PORT)
zones = htd_item_config.get(CONF_ZONES)
sources = htd_item_config.get(CONF_SOURCES)
retry_attempts = htd_item_config.get(CONF_RETRY_ATTEMPTS)
command_delay = htd_item_config.get(CONF_COMMAND_DELAY)
socket_timeout = htd_item_config.get(CONF_SOCKET_TIMEOUT)
update_volume_on_change = htd_item_config.get(
CONF_UPDATE_VOLUME_ON_CHANGE
)

if zones is None:
zones = []
Expand All @@ -58,11 +89,22 @@ def setup(hass: HomeAssistant, config: ConfigType):
for i in range(len(sources), 6):
sources.append("Source " + str(i + 1))

configs.append({
"zones": zones,
"sources": sources,
"client": HtdMcClient(host, port),
})
client = HtdMcClient(
host,
port=port,
command_delay=command_delay,
retry_attempts=retry_attempts,
socket_timeout=socket_timeout,
)

configs.append(
{
"zones": zones,
"sources": sources,
"client": client,
"update_volume_on_change": update_volume_on_change,
}
)

hass.data[DOMAIN] = configs

Expand Down
Loading

0 comments on commit 465d6b4

Please sign in to comment.