selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

GitHub
broadlink-mqtt logo

Self-host broadlink-mqtt

MQTT bridge for controlling BroadLink IR/RF devices

BetaOpen SourceMIT
Updated2 years ago
LanguagePython
Setup difficultyModerate
Stars
238
Requires
MQTT Broker
Install with Docker

What is broadlink-mqtt?

broadlink-mqtt is a Python-based MQTT client that enables control of BroadLink smart home devices through an MQTT broker. It supports a wide range of BroadLink devices including RM Pro/RM2/RM3/RM4 IR/RF controllers, SP1/SP2 smart plugs, A1 sensors, MP1 power strips, Dooya DT360E curtain motors, and BG1 smart sockets. Users can record and replay IR/RF commands, create macros, and subscribe to periodic sensor updates (temperature, humidity, energy usage, air quality, curtain position). The software runs as a standalone Python script or via Docker, and includes a systemd service file for auto-start on Linux. Configuration is done through INI-style config files with support for multiple devices on the same network.

Should you self-host broadlink-mqtt?

broadlink-mqtt scores 44/100 on selfhost.directory (how scoring works) and ranks #80 of 104 in Home Automation. It has 238 GitHub stars.

There was no stable release in the past 12 months, so check the repository's recent activity before you rely on it.

Setup is moderate: expect some configuration beyond a single command. It is MIT-licensed and written mostly in Python.

Its closest alternative on selfhost.directory is Home Assistant (91/100, 91 789 stars). It scores higher overall, so compare the two before you pick. See broadlink-mqtt vs Home Assistant side by side.

Features

  • BG1 Smart Socket Control
  • Curtain Motor Control
  • Curtain Position Monitoring
  • Energy Monitoring
  • Environmental Sensor Monitoring
  • IR/RF Command Recording and Replay
  • Macro Support
  • MQTT Bridge for BroadLink Devices
  • MQTT TLS support
  • Multiple Device SupportExperimental feature
  • Power Strip Control and Monitoring
  • Smart Mode (Auto Record/Replay)
  • Systemd Service
  • Temperature and humidity monitoring

broadlink-mqtt README

How to install broadlink-mqtt

Install broadlink-mqtt with Docker

Docker

FROM python:3.7.9

based on https://github.com/pfichtner/docker-mqttwarn

install python libraries (TODO: any others?)

#RUN pip install paho-mqtt broadlink

build /opt/mqttwarn

RUN mkdir -p /opt/broadlink-mqtt WORKDIR /opt/broadlink-mqtt RUN mkdir -p /var/log/broadlink

COPY ./requirements.txt /opt/broadlink-mqtt RUN pip install -r /opt/broadlink-mqtt/requirements.txt

add user mqttwarn to image

RUN groupadd -r broadlink && useradd -r -g broadlink broadlink RUN chown -R broadlink:broadlink /opt/broadlink-mqtt RUN chown -R broadlink:broadlink /var/log/broadlink #RUN chown -R broadlink /home/broadlink

process run as mqttwarn user

USER broadlink

conf file from host

VOLUME ["/opt/broadlink-mqtt/conf"]

commands dir

VOLUME ["/opt/broadlink-mqtt/commands/"]

set conf path

ENV BROADLINKMQTTCONFIG="/opt/broadlink-mqtt/conf/mqtt.conf" ENV BROADLINKMQTTCONFIGCUSTOM="/opt/broadlink-mqtt/conf/custom.conf"

finally, copy the current code (ideally we'd copy only what we need, but it

is not clear what that is, yet)

COPY . /opt/broadlink-mqtt

run process

CMD python mqtt.py

Dockerfile provided in repository; no pre-built image published

How to configure broadlink-mqtt

  • broadlink_a1_sensors_interval30Interval in seconds for publishing A1 sensor data

    Interval in seconds for publishing A1 sensor data

  • broadlink_a1_sensors_jsonFalseSend all A1 sensor data as a single JSON object

    Send all A1 sensor data as a single JSON object

    values: True, False

  • broadlink_a1_sensors_text_valuesFalseUse text representation for light/air quality/noise values

    Use text representation for light/air quality/noise values

    values: True, False

  • broadlink_bg1_state_interval30Interval in seconds for publishing BG1 device state

    Interval in seconds for publishing BG1 device state

  • broadlink_bg1_state_jsonFalseSend BG1 state as a single JSON object

    Send BG1 state as a single JSON object

    values: True, False

  • broadlink_dooya_position_interval30Interval in seconds for publishing Dooya curtain position

    Interval in seconds for publishing Dooya curtain position

  • broadlink_mp1_state_interval30Interval in seconds for publishing MP1 power strip state

    Interval in seconds for publishing MP1 power strip state

  • broadlink_mp1_state_jsonFalseSend MP1 state as a single JSON object

    Send MP1 state as a single JSON object

    values: True, False

  • broadlink_rm_temperature_interval120Interval in seconds for publishing RM device temperature

    Interval in seconds for publishing RM device temperature

  • broadlink_sp_energy_interval30Interval in seconds for publishing SP device energy usage

    Interval in seconds for publishing SP device energy usage

  • ca_certsPath to CA certificate file for MQTT TLS

    Path to CA certificate file for MQTT TLS

  • certfilePath to client certificate file for MQTT TLS

    Path to client certificate file for MQTT TLS

  • device_hostIP address of the BroadLink device (for direct connection)

    IP address of the BroadLink device (for direct connection)

  • device_macMAC address of the BroadLink device (for direct connection)

    MAC address of the BroadLink device (for direct connection)

  • device_typelookupType of BroadLink device to control. Valid options: 'lookup', 'multiple_lookup', 'rm', 'rm4', 'sp1', 'sp2', 'a1', 'mp1', 'dooya', 'bg1'

    Type of BroadLink device to control. Valid options: 'lookup', 'multiple_lookup', 'rm', 'rm4', 'sp1', 'sp2', 'a1', 'mp1', 'dooya', 'bg1'

    values: lookup, multiple_lookup, rm, rm4, sp1, sp2, a1, mp1, dooya, bg1

  • keyfilePath to client key file for MQTT TLS

    Path to client key file for MQTT TLS

  • lookup_timeout20Timeout in seconds for device discovery

    Timeout in seconds for device discovery

  • mqtt_brokerlocalhostMQTT broker hostname or IP address

    MQTT broker hostname or IP address

  • mqtt_clientidbroadlinkMQTT client ID

    MQTT client ID

  • mqtt_multiple_subprefix_format{type}_{mac_nic}/Format string for sub-prefix when using multiple_lookup device type

    Format string for sub-prefix when using multiple_lookup device type

  • mqtt_passwordMQTT password for authentication

    MQTT password for authentication

  • mqtt_port1883MQTT broker port

    MQTT broker port

  • mqtt_topic_prefixbroadlink/MQTT topic prefix for all messages

    MQTT topic prefix for all messages

  • mqtt_usernameMQTT username for authentication

    MQTT username for authentication

  • tls_versionTLS version for MQTT connection

    TLS version for MQTT connection

    values: sslv3, tlsv1, tlsv1.2

More in IoT

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…