GithubHelp home page GithubHelp logo

audioflow2mqtt's Introduction

Audioflow to MQTT Gateway

audioflow2mqtt enables local control of your Audioflow speaker switch(es) via MQTT. It supports Home Assistant MQTT discovery for easy integration. It can also automatically discover the Audioflow devices on your network via UDP discovery, or you can specify the IP address of the Audioflow devices if you don't want to use UDP discovery.


Configuration

audioflow2mqtt can be configured using environment variables or by using a configuration file named config.yaml. Example config.yaml with all possible configuration options:

mqtt:
  host: 10.0.0.2
  port: 1883
  user: user
  password: password
  qos: 1
  base_topic: audioflow2mqtt
  home_assistant: True

general:
  devices:
  - 10.0.1.100
  - 10.0.1.101
  discovery_port: 54321
  log_level: debug

Configuration options:

Variable Default Required Description
MQTT_HOST None True IP address or hostname of the MQTT broker to connect to.
MQTT_PORT 1883 True The port the MQTT broker is bound to.
MQTT_USER None False The user to send to the MQTT broker.
MQTT_PASSWORD None False The password to send to the MQTT broker.
MQTT_QOS 1 False The MQTT QoS level.
BASE_TOPIC audioflow2mqtt True The topic prefix to use for all payloads.
HOME_ASSISTANT True False Set to True to enable Home Assistant MQTT discovery or False to disable.
DEVICES None Depends* IP address(es) of your Audioflow device(s). If using environment variables, must be a comma-separated string (if multiple); otherwise, it must be a list.
* Required if you don't plan to use UDP discovery.
DISCOVERY_PORT 54321 False The port to open on the host to send/receive UDP discovery packets.
LOG_LEVEL info False Set minimum log level. Valid options are debug, info, warning, and error

How to run

Docker via docker-compose with config.yaml

  1. Create your docker-compose.yaml (or add to existing). Example docker-compose.yaml:
version: '3'
services:
  audioflow2mqtt:
    container_name: audioflow2mqtt
    image: tediore/audioflow2mqtt:stable
    volumes:
    - /path/to/config.yaml:/config.yaml
    restart: unless-stopped
    network_mode: host # only required if devices option is not set in config.yaml
  1. docker-compose up -d audioflow2mqtt

Docker via docker run with config.yaml

Example docker run command:

docker run --name audioflow2mqtt \
-v /path/to/config.yaml:/config.yaml \
--network host \ # only required if devices option is not set in config.yaml
tediore/audioflow2mqtt:stable

Docker via docker-compose without config.yaml

  1. Create your docker-compose.yaml (or add to existing). Example docker-compose.yaml with all environmental variables:
version: '3'
services:
  audioflow2mqtt:
    container_name: audioflow2mqtt
    image: tediore/audioflow2mqtt:stable
    environment:
    - MQTT_HOST=10.0.0.2
    - MQTT_PORT=1883
    - MQTT_USER=user
    - MQTT_PASSWORD=password
    - MQTT_QOS=1
    - BASE_TOPIC=audioflow2mqtt
    - HOME_ASSISTANT=True
    - DEVICES=10.0.1.100,10.0.1.101
    - DISCOVERY_PORT=54321
    - LOG_LEVEL=debug
    restart: unless-stopped
    network_mode: host # only required if DEVICES variable is not set
  1. docker-compose up -d audioflow2mqtt

Docker via docker run without config.yaml

Example docker run command with all environment variables:

docker run --name audioflow2mqtt \
-e MQTT_HOST=10.0.0.2 \
-e MQTT_PORT=1883 \
-e MQTT_USER=user \
-e MQTT_PASSWORD=password \
-e MQTT_QOS=1 \
-e BASE_TOPIC=audioflow2mqtt \
-e HOME_ASSISTANT=True \
-e DEVICES=10.0.1.100,10.0.1.101 \
-e LOG_LEVEL=debug \
--network host \ # only required if DEVICES variable is not set
tediore/audioflow2mqtt:stable

Bare metal (not recommended)

  1. Set the necessary environment variables or create config.yaml
  2. git clone https://github.com/Tediore/audioflow2mqtt
  3. cd audioflow2mqtt
  4. python3 audioflow2mqtt.py

Home Assistant

audioflow2mqtt supports Home Assistant MQTT discovery which creates a Device for the Audioflow switch with the following:

  • Switch entities for each zone
  • Button entities to turn all zones on/off
  • Sensors for SSID, RSSI (signal strength), and Wi-Fi channel

Home Assistant Device screenshot


MQTT topic structure and examples

The command topic syntax is BASE_TOPIC/serial_number/command/zone_number where BASE_TOPIC is the base topic you define, serial_number is the device serial number (found on the sticker on the bottom of the device), command is one of the below commands, and zone_number is the zone you want to control (zone A on the switch is zone number 1, zone B is zone number 2, and so on).

Valid commands are set_zone_state and set_zone_enable. The examples below assume the base topic is the default (audioflow2mqtt) and the serial number is 0123456789.

Turn zone B (zone number 2) on or off, or toggle between states

Topic: audioflow2mqtt/0123456789/set_zone_state/2

Valid payloads: on, off, toggle

Turn all zones on or off

Topic: audioflow2mqtt/0123456789/set_zone_state (note the lack of a zone number at the end of the topic)

Valid payloads: on, off

Enable or disable zone A (zone number 1) This might not really be something you would need, but I figured I'd add it anyway

Topic: audioflow2mqtt/0123456789/set_zone_enable/1

Valid payloads: 1 for enabled, 0 for disabled


When the zone state or enabled/disabled status is changed, audioflow2mqtt publishes the result to the following topics:

Zone state: audioflow2mqtt/0123456789/zone_state/ZONE

Zone enabled/disabled: audioflow2mqtt/0123456789/zone_enabled/ZONE


Network info is published to the following topics:

SSID: audioflow2mqtt/0123456789/network_info/ssid

Wi-fi channel: audioflow2mqtt/0123456789/network_info/channel

RSSI: audioflow2mqtt/0123456789/network_info/rssi


Important notes

When running separate instances for multiple devices, you will need to set a different base topic for each instance. Also, while audioflow2mqtt does support UDP discovery of Audioflow devices, creating a DHCP reservation for your Audioflow device(s) and setting DEVICES is recommended. UDP discovery will only work if the Audioflow device is on the same subnet as the machine audioflow2mqtt is running on.


Buy Me A Coffee

TODO

  1. Handle Audioflow device disconnects/reconnects
  2. Add support for re-discovery of Audioflow switch if its IP address changes
  3. Add support for multiple Audioflow switches? Not sure how many people would have more than one.
  4. You tell me!

audioflow2mqtt's People

Contributors

daviddesloovere avatar tediore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

0nikola1 amscanne

audioflow2mqtt's Issues

Home assistant - Hacs Custom Intergration

Not sure if this is the intended installation method through Home Assistant HACS, hopefully you can let me know

Hacs
Custom Integration, when trying the download the following error comes up
<Integration Tediore/audioflow2mqtt> Repository structure for 0.7.0 is not compliant

Blocking Strategy

According to Wikipedia ProtonVPN has 1500 servers in 61 countries, blocking all of them will almost certainly create collateral damage and affect other users, but hey if that's your plan. I'm going to start with big west coast metros first and then move to the biggest populations centers working my way down.

Seems like an awful lot of trouble to go through to keep one person out, and personally I've never gotten the entire network of a multi-national organization blocked before, so ACHIEVEMENT UNLOCKED!

Doesn't run on Raspberry pi install of HA

Hi,
When trying to run this on a home assistant install on Raspberry pi I am given this error message:

"[Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested"

I'm unable to run this on Pi 4.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.