{"id":13585100,"url":"https://github.com/eschava/broadlink-mqtt","last_synced_at":"2026-01-18T07:58:03.394Z","repository":{"id":14732496,"uuid":"76959877","full_name":"eschava/broadlink-mqtt","owner":"eschava","description":"MQTT client to control BroadLink devices","archived":false,"fork":false,"pushed_at":"2024-05-27T15:22:38.000Z","size":90,"stargazers_count":231,"open_issues_count":20,"forks_count":61,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-04-07T06:35:31.851Z","etag":null,"topics":["broadlink","home-automation","internet-of-things","iot","ir-signal","mqtt","mqtt-client","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eschava.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-20T13:42:47.000Z","updated_at":"2025-03-19T16:14:21.000Z","dependencies_parsed_at":"2023-11-20T12:26:15.433Z","dependency_job_id":"c0c3fed0-bc95-4e17-98c0-224d005bf59d","html_url":"https://github.com/eschava/broadlink-mqtt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eschava/broadlink-mqtt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschava%2Fbroadlink-mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschava%2Fbroadlink-mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschava%2Fbroadlink-mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschava%2Fbroadlink-mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eschava","download_url":"https://codeload.github.com/eschava/broadlink-mqtt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschava%2Fbroadlink-mqtt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28533512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["broadlink","home-automation","internet-of-things","iot","ir-signal","mqtt","mqtt-client","python"],"created_at":"2024-08-01T15:04:44.616Z","updated_at":"2026-01-18T07:57:58.380Z","avatar_url":"https://github.com/eschava.png","language":"Python","funding_links":[],"categories":["Interfaces","Python"],"sub_categories":["Home Entertainment"],"readme":"# MQTT client to control BroadLink devices\n\n* Supported devices\n    * [**RM Pro / RM2 / RM3 mini / RM4**](#rm2rm3rm4) IR/RF controllers (device_type = 'rm' or 'rm4')\n    * [**SP1/SP2**](#sp1sp2) smart plugs (device_type = 'sp1' or 'sp2')\n    * [**A1**](#a1) sensor (device_type = 'a1')\n    * [**MP1**](#mp1) power strip (device_type = 'mp1')\n    * [**Dooya DT360E**](#dooya-dt360e) curtain motor (device_type = 'dooya')\n    * [**BG1**](#bg1) BG smart socket (device_type = 'bg1')\n* [Installation](#installation)\n* [Configuration](#configuration)\n    * [Multiple devices configuration](#multiple-devices-configuration)\n* [Connect Broadlink device to wifi](#connect-broadlink-device-to-wifi)\n* [Start](#start)\n    * [Auto-startup (Linux)](#auto-startup--linux-)\n* [Error messages](#error-messages)\n\n \n## Installation\nClone *broadlink-mqtt* repository using  \n`git clone https://github.com/eschava/broadlink-mqtt.git`  \nor download and unpack latest archive from  \nhttps://github.com/eschava/broadlink-mqtt/archive/master.zip\n\nEnsure that a python development environment is setup:\n`sudo apt-get install python-pip python-dev`\n\nEnsure that the *libffi-dev* and *libssl-dev* packages are installed:\n`sudo apt-get install libffi-dev libssl-dev`\n\nFrom the newly created  *broadlink-mqtt* folder, install the required Python modules:\n`pip install -r requirements.txt`\n\n## Configuration\nBy default, *broadlink-mqtt* will configure using parameters from `mqtt.conf`. This configuration file may be altered during a repository update, so another configuration file is provided for editing: `custom.conf`. This will not be overwritten when updating *broadlink-mqtt*.\n\n`custom.conf` overrides `mqtt.conf`. Copy the contents of `mqtt.conf` into `custom.conf` and continue editing only `custom.conf`. \n\nRecorded commands are saved under the `commands/` folder  \nMacros are saved under the `macros/` folder\n\n### Multiple devices configuration\nUsually *broadlink-mqtt* works with single Broadlink device only, but there is an experimental feature to support several devices connected to the same network.   \nConfiguration parameters:   \n`device_type = 'multiple_lookup'`  \n`mqtt_multiple_subprefix_format = '{type}_{mac_nic}/'`  \nSecond parameter defines format of sub-prefix for every found device. E.g. for RM2 device having MAC address 11:22:33:44:55:66, MQTT prefix will be  \n`broadlink/RM2_44_55_66/`  \nFormat supports next placeholders:  \n   * `{type}` - type of the device (RM2, A1, etc)  \n   * `{host}` - host name of the device  \n   * `{mac}` - MAC address of the device  \n   * `{mac_nic}` - last 3 octets of the MAC address (NIC)  \n\n## Connect Broadlink device to wifi\nYou need to use the [Broadlink e-control app](https://play.google.com/store/apps/details?id=com.broadlink.rmt) or [Broadlink Intelligent Home Center](https://play.google.com/store/apps/details?id=cn.com.broadlink.econtrol.plus) to get the device connected to wifi. **Don't use** [BroadLink -Universal TV Remote](https://play.google.com/store/apps/details?id=cn.com.broadlink.econtrol.international), as it is known to lock devices. Other apps have not been tested.\n\nPress the reset-button for 5+ seconds till the led starts flashing continuously. Now it is in \"smart mode\". Go to the `e-control` or `Intelligent home Center` app and add a new device. Fill in the wifi-credentials and start scanning while staying close to the device. When the led starts flashing slower, it is discovered. When the led turns off, it is configured.\n\nYou (theoretically) can configure multiple devices at one.\n\n## Start\nJust start `mqtt.py` script using Python interpreter. You may have to use `python3`.\n\n### Auto-startup (Linux)\n(From https://github.com/eschava/broadlink-mqtt/issues/29#issuecomment-630254666)\n\n    sudo nano /lib/systemd/system/broadlink-mqtt.service\n\nCopy and paste the following, then save:\n\n`[Unit]`  \n`Description=Broadlink MQTT Service`  \n`After=multi-user.target`  \n`Conflicts=getty@tty1.service` \n\n`[Service]`  \n`Type=simple`  \n`ExecStart=/usr/bin/python3 /home/pi/broadlink-mqtt/mqtt.py`  \n`StandardInput=tty-force`  \n\n`[Install]`  \n`WantedBy=multi-user.target`\n\nReload the daemon:\n`sudo systemctl daemon-reload`\n\nTo start the service:  \n`sudo systemctl start broadlink-mqtt.service`\n    \nTo see the service status:  \n`sudo systemctl status broadlink-mqtt.service`\n    \nTo stop the service:  \n`sudo systemctl stop broadlink-mqtt.service`\n    \nTo restart the service:  \n`sudo systemctl restart broadlink-mqtt.service`\n\n## Error messages\n- **ERROR No Broadlink devices found**: No wifi-device on the network is a Broadlink device recognized by the library. If you see a device connected to your wifi that starts with the device type, like \"RM4-44-b6-a2\" for a RM4, then it could be that the device is not supported yet. If you see no device connected (which is in most cases), make sure it is connected to your wifi network.\n- **broadlink.exceptions.AuthenticationError: Authentication failed**: The device is locked by an app. Use the instructions above to reset the device and connect it to wifi without lock.\n- **with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: AttributeError: __exit__**: this library requires Python3, and you used Python2. Start the library with `python3 ./mqtt.py`.\n- **ERROR MQTT topic broadlink/RMx_xx_xx_xx/projector/power has no recognized device reference, expected one of RMy_yy_yy_yy/**: replace the device ID `RMx_xx_xx_xx` with `RMy_yy_yy_yy` in your mqtt-command.\n- **FileNotFoundError: [Errno 2] No such file or directory: '/opt/broadlink-mqtt/commands/projector/power'**: You need to manually create a directory per device.\n- **WARNING OOOOPS! MQTT disconnection**: It happens\n\nIf you think you see reasons to improve the library, you are very welcome to contribute!\n\n# RM2/RM3/RM4\n### MQTT commands to control IR/RF\n#### Recording (IR or RF)\nTo record new command just send `record` message for IR command or `recordrf` for RF command to the topic `broadlink/COMMAND_ID`,  \nwhere COMMAND_ID is any identifier that can be used for file name (slashes are also allowed)  \n\u003e **NOTE**: It seems that Python3 is a must for recording RF signals  \n\n**Example**: to record power button for Samsung TV send  \n`record` -\u003e `broadlink/tv/samsung/power`  \nand recorded interpretation of IR signal will be saved to file `commands/tv/samsung/power`\n\n#### Replay\nTo replay previously recorded command send `replay` message to the topic `broadlink/COMMAND_ID`,  \nwhere COMMAND_ID is identifier if the command  \n**Example**: to replay power button for Samsung TV send  \n`replay` -\u003e `broadlink/tv/samsung/power`  \nand saved interpretation of IR signal will be replayed from file `commands/tv/samsung/power`\n\nAnother format for replaying recorded command is using file name as a message and folder as MQTT topic.  \n**Example**: to replay power button for Samsung TV send  \n`power` -\u003e `broadlink/tv/samsung`  \nand saved interpretation of IR signal will be replayed from file `commands/tv/samsung/power`\n\n#### Smart mode\nSmart mode means that if file with command doesn't exist it will be recorded.  \nEvery next execution of the command will replay it.  \nThis mode is very convenient for home automation systems.  \nTo start smart mode need to send `auto` for IR command or `autorf` for RF command to the command topic   \n**Example:**  \nfirst time: `auto` -\u003e `broadlink/tv/samsung/power` records command  \nevery next time: `auto` -\u003e `broadlink/tv/samsung/power` replays command  \n\n#### Macros\nMacro command sends several IR signals for single MQTT message.  \nTo start macros execution send `macro` message to the topic `broadlink/MACRO_ID`,  \nwhere `MACRO_ID` is a path to scenario file in `macros/` folder.  \nAlternative way of sending macro command is sending `MACRO_ID` message to the `broadlink/macro` topic.  \n\nMacros scenario file could contain:\n - IR commands (same as `COMMAND_ID` in replay mode)\n - pause instructions (`pause DELAY_IN_MILLISECONDS`)\n - comments (lines started with `#`)\n \n### Subscription to current temperature (RM2/RM4 devices)\nNeed to set `broadlink_rm_temperature_interval` configuration parameter to a number of seconds between periodic updates.  \nE.g. \n`broadlink_rm_temperature_interval`=120\nmeans current temperature will be published to topic `broadlink/temperature` every 2 minutes\n\n# SP1/SP2\n### MQTT commands to control power\nTo switch power on (off) need to send command `on` (`off`) to `broadlink/power` topic  \nCommands `1` / `0` are also supported\n\n### Subscription to current used energy (SP2 device)\nNeed to set `broadlink_sp_energy_interval` configuration parameter to a number of seconds between periodic updates.  \nE.g.  \n`broadlink_sp_energy_interval`=120  \nmeans current used energy will be published to topic `broadlink/energy` every 2 minutes\n\n# A1\n### Subscription to current sensors data\nNeed to set `broadlink_a1_sensors_interval` configuration parameter to a number of seconds between periodic updates.  \nE.g.  \n`broadlink_a1_sensors_interval`=120\nmeans current sensors data will be published to topics `broadlink/sensors/[temperature/humidity/light/air_quality/noise]` every 2 minutes  \n\n# MP1\n### MQTT commands to control power\nTo switch power on (off) on outlet number N need to send command `on` (`off`) to `broadlink/power/N` topic.  \nCommands `1` / `0` are also supported  \n**Example:**  \nswitch on 2-nd outlet: `on` -\u003e `broadlink/power/2`\n\n### Subscription to current state\nNeed to set `broadlink_mp1_state_interval` configuration parameter to a number of seconds between periodic updates.  \nE.g.  \n`broadlink_mp1_state_interval`=120  \nmeans current state will be published to topics `broadlink/state/[s1/s2/s3/s4]` every 2 minutes    \n\n# Dooya DT360E\n### MQTT commands to control curtain motor\nTo open/close curtains need to send a command to `broadlink/action` topic.  \nPossible commands are:  \n  - `open` to open curtains\n  - `close` to close curtains\n  - `stop` to stop curtains in the current state  \n\nAlso it's possible to set fixed position of curtains sending numeric position in percents to the topic `broadlink/set`\n\n### Subscription to current curtain position\nNeed to set `broadlink_dooya_position_interval` configuration parameter to a number of seconds between periodic updates.  \nE.g.  \n`broadlink_dooya_position_interval`=30  \nmeans current curtain position in percents will be published to topic `broadlink/position` every 30 seconds  \n\n# BG1\n### MQTT commands to control\nTo change brightness of LED need to send value in percents to `broadlink/brightness` topic  \nTo switch power on (off) on all (or single only) outlets need to send command `on` (`off`) to `broadlink/power` topic.  \nTo switch power on (off) on outlet number N need to send command `on` (`off`) to `broadlink/power/N` topic.  \nCommands `1` / `0` are also supported  \n**Example:**  \nswitch on 2-nd outlet: `on` -\u003e `broadlink/power/2`  \n\n### Subscription to current state\nNeed to set `broadlink_bg1_state_interval` configuration parameter to a number of seconds between periodic updates.  \nE.g.  \n`broadlink_bg1_state_interval`=120  \nmeans current state will be published to topics `broadlink/state/[pwr/pwr1/pwr2/maxworktime/maxworktime1/maxworktime2/idcbrightness]` every 2 minutes    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feschava%2Fbroadlink-mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feschava%2Fbroadlink-mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feschava%2Fbroadlink-mqtt/lists"}