I finally have some time to complete the documentation of my project and have made it public.
https://github.com/rabbit-aaron/marshall-stanmore-2
This library allows you to control your Marshall Stanmore 2 speaker using Python, and there’s an MQTT client that allows you to integrate this with Home Assistant or other home automation tools.
To run it, you will need some basic Python knowledge.
- Find your BLE address, you can use tools like nRF [Connect for Mobile] (nRF Connect for Mobile on the App Store). There’s also an Android version.
- Ensure you have python 3.11+ installed.
- Clone the repository, cd into it
- Create a virtual environment:
python -m venv .venv
- Activate the virtual environment
source .venv/bin/activate
- Install the dependencies
pip install -r requirements.txt
- Run the MQTT server with environment variables, you can turn the below into a bash script so you can run it like an executable.
#!/usr/bin/env bash
export BLE_ADDRESS=<your speaker BLE address>
export MQTT_HOSTNAME=<your mqtt host>
export MQTT_PORT=<your mqtt port> # optional, default is 1883
export MQTT_USERNAME=<username> #optional default is None, if you didn't enable authentication
export MQTT_PASSWORD =<password> #optional default is None, if you didn't enable authentication
export MQTT_TOPIC_PREFIX = <mqtt topic prefix> # optional, default is "stanmore2"
export MQTT_RETAIN=<TRUE or FALSE> # optional, default is False, this sets the mqtt message retain flag
export ALLOW_PAIRING=<TRUE or FALSE> # optional, default is FALSE, whether to allow MQTT to turn the speaker into Bluetooth pairing mode. Note that when entering the pairing mode, BLE control disconnects.
/path/to/.venv/bin/python -m marshallstanmore2
See the readme for the MQTT commands and output you can use. Here’s my configuration.
mqtt:
- number:
command_topic: stanmore2/command/set_eq_profile/160hz
state_topic: stanmore2/info/eq_profile/160hz
availability_topic: stanmore2/lwt
min: 0
max: 10
step: 1
name: Stanmore2 EQ 160hz
icon: mdi:equalizer
- number:
command_topic: stanmore2/command/set_eq_profile/400hz
state_topic: stanmore2/info/eq_profile/400hz
availability_topic: stanmore2/lwt
min: 0
max: 10
step: 1
name: Stanmore2 EQ 400hz
icon: mdi:equalizer
- number:
command_topic: stanmore2/command/set_eq_profile/1000hz
state_topic: stanmore2/info/eq_profile/1000hz
availability_topic: stanmore2/lwt
min: 0
max: 10
step: 1
name: Stanmore2 EQ 1khz
icon: mdi:equalizer
- number:
command_topic: stanmore2/command/set_eq_profile/2500hz
state_topic: stanmore2/info/eq_profile/2500hz
availability_topic: stanmore2/lwt
min: 0
max: 10
step: 1
name: Stanmore2 EQ 2.5khz
icon: mdi:equalizer
- number:
command_topic: stanmore2/command/set_eq_profile/6250hz
state_topic: stanmore2/info/eq_profile/6250hz
availability_topic: stanmore2/lwt
min: 0
max: 10
step: 1
name: Stanmore2 EQ 6.25khz
icon: mdi:equalizer
- number:
command_topic: stanmore2/command/set_volume
state_topic: stanmore2/info/volume
availability_topic: stanmore2/lwt
min: 0
max: 32
step: 1
name: Stanmore2 Volume
icon: mdi:knob
- select:
name: Stanmore2 EQ Preset
command_topic: stanmore2/command/set_eq_preset
state_topic: stanmore2/info/eq_preset
availability_topic: stanmore2/lwt
icon: mdi:equalizer
value_template: "{{ value.upper() }}"
command_template: "{{ value.lower() }}"
options:
- FLAT
- ROCK
- METAL
- POP
- HIPHOP
- ELECTRONIC
- JAZZ
- CUSTOM
- select:
name: Stanmore2 Audio Source
command_topic: stanmore2/command/set_source
state_topic: stanmore2/info/audio_source
availability_topic: stanmore2/lwt
icon: mdi:audio-input-rca
value_template: "{{ value.upper() }}"
command_template: "{{ value.lower() }}"
options:
- BLUETOOTH
- AUX
- RCA
Let me know if you have trouble running it, if more people are interested in this project I can make it into a docker container so you can just pull and run.
Note, the top integration in the screenshot is [an integration with Shairport-sync].(GitHub - parautenbach/hass-shairport-sync: A custom media player for Home Assistant that allows you to control and get updates from a Shairport Sync installation using MQTT.)
I have another program running to capture shairport-sync’s MQTT message and use that to transform and forward MQTT message to my program, and that allow me to directly control speaker volume from my iPhone/Mac. If anyone’s interested I can open source this too. Alternatively you can do this via HA automation or NodeRed.