https://github.com/aranajuan/broadlink-bridge
369
Forked from https://github.com/lbschenkel/broadlink-bridgeā to https://github.com/aranajuan/broadlink-bridgeā
Added:
A HTTP/MQTT/LIRC bridge to Broadlink IR/RF devices, written in Python and powered by python-broadlinkā .
š š§ EXPERIMENTAL / WORK IN PROGRESS š§ š
Note: that there is a similar project for Node.jsā with the same name.
To install: pip install [--user] git+https://github.com/lbschenkel/broadlink-bridge.git
To run: broadlink-bridge [config-file]
docker run -v ${PWD}/config:/config -p 8780:8780 aranajuan/broadlink-bridge:latest
This bridge is available as an unnoficial add-onā .
Codes can be transmitted via RESTful commandsā :
rest_command:
my_command:
url: http://BRIDGE_HOST:PORT/device/DEVICE
method: post
payload: CODE
Or by publishing via MQTTā , for example in an entity button:
type: entity-button
name: My command
entity: ...
tap_action:
action: call-service
service: mqtt.publish
service_data:
topic: PREFIX/device/DEVICE/transmit
payload: CODE
An on/off switch can be implemented directly via a MQTT switchā :
switch:
- platform: mqtt
command_topic: PREFIX/device/DEVICE/transmit
payload_on: CODE
payload_off: CODE
Or by combining RESTful commands with a boolean inputā and an automationā :
rest_command:
my_device_on:
url: http://BRIDGE_HOST:PORT/device/DEVICE
method: post
payload: CODE
my_device_off:
url: http://BRIDGE_HOST:PORT/device/DEVICE
method: post
payload: CODE
input_boolean:
my_device:
name: My Device
automation:
trigger:
platform: state
entity_id: input_boolean.my_device
action:
service_template: rest_command.my_device_{{ trigger.to_state.state }}
Note that the RESTful switchā is not useful, because it relies on the REST endpoint providing the state (not possible here) and it does not implement an optimistic mode with an assumed state (like the MQTT switch does).
In the above:
BRIDGE_HOST is the hostname/IP address of this bridgePORT is the HTTP port (default 8780)PREFIX is the MQTT prefix (default broadlink)DEVICE identifies the target deviceā CODE is the codeā (or command) to transmit,
prefixed by any repeatsā A configuration file can be optionally specified as a command-line argument. An example fileā is provided.
To enable the MQTT client, it is necessary to specify the URL of the MQTT
broker as the broker_url value inside the [mqtt] section.
The prefix for the MQTT topics is configurable via topic_prefix.
Devices can be manually declared in the [devices] section. When a device is
declared in this way it is given an alias which can act as an additional
identifierā for the device in the bridge.
Auto-discovered devices do not have aliases.
Commands can be defined in the [commands] section. Commands associate a
name with a code. The name can then be used anywhere where a code can appear.
The code for the command can be in any supported formatā and contain repeatsā , with the exception that it cannot be another command.
A device represents a Broadlink device which can be addressed on any of the protocols. It can be identified by any of the following:
When the device is not found via one of the mechanisms above, a final attempt is made by interpreting device as a host: in case a device is discovered at that address, then it is added to the list of known devices (this can be considered a lazy discovery mechanism).
The default device is the deviceā with an alias of default. If there is no device with such an alias, it is the first declared or discovered device.
The code is the data to transmit. It can have one of the following forms:
IR/RF data in Broadlink format (encoded as base64):
JgAcAB0dHB44HhweGx4cHR06HB0cHhwdHB8bHhwADQUAAAAAAAAAAAAAAAA=
IR data in Pronto hex format:
0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0041 0016 0016 0016
0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0016 0016 0041
0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0016 0016 0041 0016
0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016
0016 0041 0016 0041 0016 0041 0016 0016 0016 0016 0016 05F7 015B 0057 0016
0E6C
a command defined via the configuration file: in that case the code for the command is used (which can have any of the above forms)
Note that codes can contain repeats (see next section).
Repeats are the number of times a code will be retransmitted. Repeats can be specified in multiple ways:
N* (number plus asterisk)
then the code will be sent N times (N-1 repeats), for example:
3 * JgAcAB... (Broadlink format, sent 3 times)2 * 0000 006C ... (Pronto hex format, sent 2 times)5 * tv/on (command defined via configuration file, sent 5 times)When repeats are specified in more than one way, their effects multiply.
For example, LIRC command SEND_ONCE default 3*tv/on 1 (1 being the repeat
and tv/on being a command defined in the configuration file as 2*JgAcAB...)
will result in the code being sent 2x3x2 = 12 times (11 repeats).
| verb | path | description |
|---|---|---|
| POST | /device/device | transmits the submitted codeā via deviceā |
| POST | /device/device/temperature | get temperature |
Status codes:
404 when the device is unknown400 when the code is invalid or not recognizedThe topic prefix defaults to broadlink and can be changed via the configuration file.
A subset of the LIRC command interfaceā and the unofficial CCF extensionā is supported.
| command | description |
|---|---|
| SEND_ONCE device code [repeat] | transmits the given codeā (no spaces) via deviceā , optionally repeating it repeat times |
| SEND_CCF_ONCE repeat code | transmits the given codeā (spaces allowed) via the default deviceā , repeating it repeat times |
| LIST | replies with all known devices |
| LIST device | replies with all defined commands (commands are not device-specific) |
| VERSION | replies with bridge version |
Content type
Image
Digest
Size
25.5 MB
Last updated
over 5 years ago
docker pull aranajuan/broadlink-bridge