Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/pip-gte-21.0-and-lt-23.4
Browse files Browse the repository at this point in the history
  • Loading branch information
wrodie authored Nov 4, 2023
2 parents b0e3f6c + 24c9590 commit 458f59d
Show file tree
Hide file tree
Showing 31 changed files with 663 additions and 556 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ body:
required: true
- label: This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
required: true
- label: This issue is not a duplicate issue of currently [previous issues](https://github.com/ludeeus/integration_blueprint/issues?q=is%3Aissue+label%3A%22Bug%22+)..
- label: This issue is not a duplicate issue of currently [previous issues](https://github.com/wrodie/ha_behringer_mixer/issues?q=is%3Aissue+label%3A%22Bug%22+)..
required: true
- type: textarea
attributes:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ body:
required: true
- label: This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request).
required: true
- label: This issue is not a duplicate feature request of [previous feature requests](https://github.com/ludeeus/integration_blueprint/issues?q=is%3Aissue+label%3A%22Feature+Request%22+).
- label: This issue is not a duplicate feature request of [previous feature requests](https://github.com/wrodie/ha_behringer_mixer/issues?q=is%3Aissue+label%3A%22Feature+Request%22+).
required: true

- type: textarea
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v3.5.2"
uses: "actions/checkout@v4.1.1"

- name: "Set up Python"
uses: actions/setup-python@v4.6.1
uses: actions/setup-python@v4.7.1
with:
python-version: "3.10"
cache: "pip"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ jobs:
contents: write
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v3.5.2"
uses: "actions/checkout@v4.1.1"

- name: "Adjust version number"
shell: "bash"
run: |
yq -i -o json '.version="${{ github.event.release.tag_name }}"' \
"${{ github.workspace }}/custom_components/integration_blueprint/manifest.json"
"${{ github.workspace }}/custom_components/ha_behringer_mixer/manifest.json"
- name: "ZIP the integration directory"
shell: "bash"
run: |
cd "${{ github.workspace }}/custom_components/integration_blueprint"
zip integration_blueprint.zip -r ./
cd "${{ github.workspace }}/custom_components/ha_behringer_mixer"
zip ha_behringer_mixer.zip -r ./
- name: "Upload the ZIP file to the release"
uses: softprops/action-gh-release@v0.1.15
with:
files: ${{ github.workspace }}/custom_components/integration_blueprint/integration_blueprint.zip
files: ${{ github.workspace }}/custom_components/ha_behringer_mixer/ha_behringer_mixer.zip
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v3.5.2"
uses: "actions/checkout@v4.1.1"

- name: "Run hassfest validation"
uses: "home-assistant/actions/hassfest@master"
Expand All @@ -27,7 +27,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v3.5.2"
uses: "actions/checkout@v4.1.1"

- name: "Run HACS validation"
uses: "hacs/action@main"
Expand Down
130 changes: 83 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,83 @@
# Notice

The component and platforms in this repository are not meant to be used by a
user, but as a "blueprint" that custom component developers can build
upon, to make more awesome stuff.

HAVE FUN! 😎

## Why?

This is simple, by having custom_components look (README + structure) the same
it is easier for developers to help each other and for users to start using them.

If you are a developer and you want to add things to this "blueprint" that you think more
developers will have use for, please open a PR to add it :)

## What?

This repository contains multiple files, here is a overview:

File | Purpose | Documentation
-- | -- | --
`.devcontainer.json` | Used for development/testing with Visual Studio Code. | [Documentation](https://code.visualstudio.com/docs/remote/containers)
`.github/ISSUE_TEMPLATE/*.yml` | Templates for the issue tracker | [Documentation](https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository)
`.vscode/tasks.json` | Tasks for the devcontainer. | [Documentation](https://code.visualstudio.com/docs/editor/tasks)
`custom_components/integration_blueprint/*` | Integration files, this is where everything happens. | [Documentation](https://developers.home-assistant.io/docs/creating_component_index)
`CONTRIBUTING.md` | Guidelines on how to contribute. | [Documentation](https://help.github.com/en/github/building-a-strong-community/setting-guidelines-for-repository-contributors)
`LICENSE` | The license file for the project. | [Documentation](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/licensing-a-repository)
`README.md` | The file you are reading now, should contain info about the integration, installation and configuration instructions. | [Documentation](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax)
`requirements.txt` | Python packages used for development/lint/testing this integration. | [Documentation](https://pip.pypa.io/en/stable/user_guide/#requirements-files)

## How?

1. Create a new repository in GitHub, using this repository as a template by clicking the "Use this template" button in the GitHub UI.
1. Open your new repository in Visual Studio Code devcontainer (Preferably with the "`Dev Containers: Clone Repository in Named Container Volume...`" option).
1. Rename all instances of the `integration_blueprint` to `custom_components/<your_integration_domain>` (e.g. `custom_components/awesome_integration`).
1. Rename all instances of the `Integration Blueprint` to `<Your Integration Name>` (e.g. `Awesome Integration`).
1. Run the `scripts/develop` to start HA and test out your new integration.

## Next steps

These are some next steps you may want to look into:
- Add tests to your integration, [`pytest-homeassistant-custom-component`](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component) can help you get started.
- Add brand images (logo/icon) to https://github.com/home-assistant/brands.
- Create your first release.
- Share your integration on the [Home Assistant Forum](https://community.home-assistant.io/).
- Submit your integration to the [HACS](https://hacs.xyz/docs/publish/start).
# Behringer Digital Mixer Integration For Home Assistant

[![GitHub Release][releases-shield]][releases]
[![GitHub Activity][commits-shield]][commits]
[![License][license-shield]](LICENSE)

[![hacs][hacsbadge]][hacs]
![Project Maintenance][maintenance-shield]


This integration allows you to connect a Behringer Digital Mixer to Home Assistant.

**Mixers Supported**
- X32
- XR12
- XR16
- XR18

*Testing has been mostly on the X32*

For each mixer configured by this integration entities for the following are provided.:

For each Channel, Bus, DCA, Matrix, and Main Faders
- Name (Read only)
- Mute (SWITCH) (Read/Write)
- Fader (NUMBER) (Read/Write)
- Fader Value - dB (SENSOR) (Read only)

In addition to these 'fader' related variables, also provided is
- Current scene/snapshot number/index (Read/Write)

## Data Updates
The data for the mixer is updated in real time, so each time a button is pressed or fader is moved on the mixer, this is updated in Home Assistant immediately.




## Installation

**HACS installation (recommended)**

1. Install HACS. That way you get updates automatically.
1. Add this Github repository as custom repository in HACS settings.
1. Aearch and install "Behringer Mixer" in HACS and click install.
1. Restart Home Assistant,
1. Then you can add a Behringer Mixer integration in the integration page.

**Manual installation**

1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`).
1. If you do not have a `custom_components` directory (folder) there, you need to create it.
1. In the `custom_components` directory (folder) create a new folder called `ha_berhringer_mixer`.
1. Download _all_ the files from the `custom_components/ha_berhringer_mixer/` directory (folder) in this repository.
1. Place the files you downloaded in the new directory (folder) you created.
1. Restart Home Assistant
1. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Behringer Mixer"



## Configuration is done in the UI

<!---->

# Caveats
Connection to the mixer is performed via ip address using UDP. If the IP address for the mixer changes, you will need to edit the integration setup. To avoid this, set up a DHCP reservation on your router for your mixer so that it always has the same IP address.

This information on changes to the mixer is written to the HA history/recorder databases so this may result in lots of state being stored if the mixer changes a lot. You may want to consider excluding these entities from storing history.




## Contributions are welcome!

If you want to contribute to this please read the [Contribution guidelines](CONTRIBUTING.md)

***


[commits]: https://github.com/wrodie/ha_behringer_mixer/commits/main
[hacs]: https://github.com/hacs/integration
[hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge
[releases-shield]: https://img.shields.io/github/release/wrodie/ha_behringer_mixer.svg?style=for-the-badge
[releases]: https://github.com/wrodie/ha_behringer_mixer/releases
59 changes: 0 additions & 59 deletions README_EXAMPLE.md

This file was deleted.

2 changes: 1 addition & 1 deletion config/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ default_config:
logger:
default: info
logs:
custom_components.integration_blueprint: debug
custom_components.ha_behringer_mixer: debug
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
"""Custom integration to integrate integration_blueprint with Home Assistant.
For more details about this integration, please refer to
https://github.com/ludeeus/integration_blueprint
"""
"""Custom integration to integrate a Behringer mixer into Home Assistant."""
from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.config_entries import ConfigEntry, ConfigEntryNotReady
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .api import IntegrationBlueprintApiClient
from .api import BehringerMixerApiClient
from .const import DOMAIN
from .coordinator import BlueprintDataUpdateCoordinator
from .coordinator import MixerDataUpdateCoordinator

PLATFORMS: list[Platform] = [
Platform.SENSOR,
Platform.BINARY_SENSOR,
Platform.SWITCH,
Platform.NUMBER,
Platform.SENSOR,
]


# https://developers.home-assistant.io/docs/config_entries_index/#setting-up-an-entry
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up this integration using UI."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = coordinator = BlueprintDataUpdateCoordinator(

client = BehringerMixerApiClient(
mixer_ip=entry.data["MIXER_IP"], mixer_type=entry.data["MIXER_TYPE"]
)
if not await client.setup():
raise ConfigEntryNotReady(
f"Timeout while connecting to {entry.data['MIXER_IP']}"
)

hass.data[DOMAIN][entry.entry_id] = coordinator = MixerDataUpdateCoordinator(
hass=hass,
client=IntegrationBlueprintApiClient(
username=entry.data[CONF_USERNAME],
password=entry.data[CONF_PASSWORD],
session=async_get_clientsession(hass),
),
client=client,
)
# https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities
await coordinator.async_config_entry_first_refresh()
client.register_coordinator(coordinator)

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(async_reload_entry))



return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Handle removal of an entry."""
if unloaded := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
hass.data[DOMAIN][entry.entry_id].client.stop()
hass.data[DOMAIN].pop(entry.entry_id)
return unloaded

Expand Down
Loading

0 comments on commit 458f59d

Please sign in to comment.