Giter Site home page Giter Site logo

broadlink-mqtt's Introduction

MQTT client to control BroadLink devices

Installation

Clone broadlink-mqtt repository using
git clone https://github.com/eschava/broadlink-mqtt.git
or download and unpack latest archive from
https://github.com/eschava/broadlink-mqtt/archive/master.zip

Ensure that a python development environment is setup: sudo apt-get install python-pip python-dev

Ensure that the libffi-dev and libssl-dev packages are installed: sudo apt-get install libffi-dev libssl-dev

From the newly created broadlink-mqtt folder, install the required Python modules: pip install -r requirements.txt

Configuration

By 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.

custom.conf overrides mqtt.conf. Copy the contents of mqtt.conf into custom.conf and continue editing only custom.conf.

Recorded commands are saved under the commands/ folder
Macros are saved under the macros/ folder

Multiple devices configuration

Usually broadlink-mqtt works with single Broadlink device only, but there is an experimental feature to support several devices connected to the same network.
Configuration parameters:
device_type = 'multiple_lookup'
mqtt_multiple_subprefix_format = '{type}_{mac_nic}/'
Second 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
broadlink/RM2_44_55_66/
Format supports next placeholders:

  • {type} - type of the device (RM2, A1, etc)
  • {host} - host name of the device
  • {mac} - MAC address of the device
  • {mac_nic} - last 3 octets of the MAC address (NIC)

Connect Broadlink device to wifi

You need to use the Broadlink e-control app or Broadlink Intelligent Home Center to get the device connected to wifi. Don't use BroadLink -Universal TV Remote, as it is known to lock devices. Other apps have not been tested.

Press 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.

You (theoretically) can configure multiple devices at one.

Start

Just start mqtt.py script using Python interpreter. You may have to use python3.

Auto-startup (Linux)

(From #29 (comment))

sudo nano /lib/systemd/system/broadlink-mqtt.service

Copy and paste the following, then save:

[Unit]
Description=Broadlink MQTT Service
After=multi-user.target
[email protected]

[Service]
Type=simple
ExecStart=/usr/bin/python3 /home/pi/broadlink-mqtt/mqtt.py
StandardInput=tty-force

[Install]
WantedBy=multi-user.target

Reload the daemon: sudo systemctl daemon-reload

To start the service:
sudo systemctl start broadlink-mqtt.service

To see the service status:
sudo systemctl status broadlink-mqtt.service

To stop the service:
sudo systemctl stop broadlink-mqtt.service

To restart the service:
sudo systemctl restart broadlink-mqtt.service

Error messages

  • 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.
  • 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.
  • 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.
  • 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.
  • FileNotFoundError: [Errno 2] No such file or directory: '/opt/broadlink-mqtt/commands/projector/power': You need to manually create a directory per device.
  • WARNING OOOOPS! MQTT disconnection: It happens

If you think you see reasons to improve the library, you are very welcome to contribute!

RM2/RM3/RM4

MQTT commands to control IR/RF

Recording (IR or RF)

To record new command just send record message for IR command or recordrf for RF command to the topic broadlink/COMMAND_ID,
where COMMAND_ID is any identifier that can be used for file name (slashes are also allowed)

NOTE: It seems that Python3 is a must for recording RF signals

Example: to record power button for Samsung TV send
record -> broadlink/tv/samsung/power
and recorded interpretation of IR signal will be saved to file commands/tv/samsung/power

Replay

To replay previously recorded command send replay message to the topic broadlink/COMMAND_ID,
where COMMAND_ID is identifier if the command
Example: to replay power button for Samsung TV send
replay -> broadlink/tv/samsung/power
and saved interpretation of IR signal will be replayed from file commands/tv/samsung/power

Another format for replaying recorded command is using file name as a message and folder as MQTT topic.
Example: to replay power button for Samsung TV send
power -> broadlink/tv/samsung
and saved interpretation of IR signal will be replayed from file commands/tv/samsung/power

Smart mode

Smart mode means that if file with command doesn't exist it will be recorded.
Every next execution of the command will replay it.
This mode is very convenient for home automation systems.
To start smart mode need to send auto for IR command or autorf for RF command to the command topic
Example:
first time: auto -> broadlink/tv/samsung/power records command
every next time: auto -> broadlink/tv/samsung/power replays command

Macros

Macro command sends several IR signals for single MQTT message.
To start macros execution send macro message to the topic broadlink/MACRO_ID,
where MACRO_ID is a path to scenario file in macros/ folder.
Alternative way of sending macro command is sending MACRO_ID message to the broadlink/macro topic.

Macros scenario file could contain:

  • IR commands (same as COMMAND_ID in replay mode)
  • pause instructions (pause DELAY_IN_MILLISECONDS)
  • comments (lines started with #)

Subscription to current temperature (RM2/RM4 devices)

Need to set broadlink_rm_temperature_interval configuration parameter to a number of seconds between periodic updates.
E.g. broadlink_rm_temperature_interval=120 means current temperature will be published to topic broadlink/temperature every 2 minutes

SP1/SP2

MQTT commands to control power

To switch power on (off) need to send command on (off) to broadlink/power topic
Commands 1 / 0 are also supported

Subscription to current used energy (SP2 device)

Need to set broadlink_sp_energy_interval configuration parameter to a number of seconds between periodic updates.
E.g.
broadlink_sp_energy_interval=120
means current used energy will be published to topic broadlink/energy every 2 minutes

A1

Subscription to current sensors data

Need to set broadlink_a1_sensors_interval configuration parameter to a number of seconds between periodic updates.
E.g.
broadlink_a1_sensors_interval=120 means current sensors data will be published to topics broadlink/sensors/[temperature/humidity/light/air_quality/noise] every 2 minutes

MP1

MQTT commands to control power

To switch power on (off) on outlet number N need to send command on (off) to broadlink/power/N topic.
Commands 1 / 0 are also supported
Example:
switch on 2-nd outlet: on -> broadlink/power/2

Subscription to current state

Need to set broadlink_mp1_state_interval configuration parameter to a number of seconds between periodic updates.
E.g.
broadlink_mp1_state_interval=120
means current state will be published to topics broadlink/state/[s1/s2/s3/s4] every 2 minutes

Dooya DT360E

MQTT commands to control curtain motor

To open/close curtains need to send a command to broadlink/action topic.
Possible commands are:

  • open to open curtains
  • close to close curtains
  • stop to stop curtains in the current state

Also it's possible to set fixed position of curtains sending numeric position in percents to the topic broadlink/set

Subscription to current curtain position

Need to set broadlink_dooya_position_interval configuration parameter to a number of seconds between periodic updates.
E.g.
broadlink_dooya_position_interval=30
means current curtain position in percents will be published to topic broadlink/position every 30 seconds

BG1

MQTT commands to control

To change brightness of LED need to send value in percents to broadlink/brightness topic
To switch power on (off) on all (or single only) outlets need to send command on (off) to broadlink/power topic.
To switch power on (off) on outlet number N need to send command on (off) to broadlink/power/N topic.
Commands 1 / 0 are also supported
Example:
switch on 2-nd outlet: on -> broadlink/power/2

Subscription to current state

Need to set broadlink_bg1_state_interval configuration parameter to a number of seconds between periodic updates.
E.g.
broadlink_bg1_state_interval=120
means current state will be published to topics broadlink/state/[pwr/pwr1/pwr2/maxworktime/maxworktime1/maxworktime2/idcbrightness] every 2 minutes

broadlink-mqtt's People

Contributors

digitlength avatar eschava avatar gnalbandian avatar juzam avatar mgr01 avatar mindstorms6 avatar nboeckmann avatar psyciknz avatar zorrigas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

broadlink-mqtt's Issues

In which format are the codes stored?

Maybe a stupid question to ask, but is there any documentation about the format used to store the IR codes (Pronto Hex? LIRC?) ? Also, are there any tools around to convert popular formats into the format broadlink-mqtt understands?

Cheers, and thanks for the great work!

ERROR No Broadlink device found

hy,
i have a two broadlinks,rm pro and rm mini
but when i start python mqtt.py it doesnt found my device
return ERROR No Broadlink device found

socket.error: [Errno 111] Connection refused

Hi
i followed your tutorial for installation of brodlink-mqtt but i run mqtt.py with interpreter pyton i had this error from server:

Traceback (most recent call last):
File "./mqtt.py", line 389, in
mqttc.connect(cf.get('mqtt_broker', 'localhost'), int(cf.get('mqtt_port', '1883')), 60)
File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 839, in connect
return self.reconnect()
File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 962, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python2.7/socket.py", line 575, in create_connection
raise err
socket.error: [Errno 111] Connection refused
The installation of linux suite is on Rabsperry pi 0 and then there is Homeassistant also istalled. I try to open the port 1883 on the gateway but it's not resolve the problem

this is my mqtt.config

Type of device. Valid options are 'lookup', 'multiple_lookup', 'rm', 'sp1', 'sp2', 'a1', 'mp1'
device_type = 'multiple_lookup' # use lookup

lookup parameters

lookup_timeout = 20
#local_address = '127.0.0.1'

parameters for direct connection

#device_host = '192.168.1.64'
#device_mac = 'b8:27:eb:d7:1b:10'
#device_mac = '01:23:45:67:ab:00'

MQTT connection parameters

mqtt_broker = 'localhost' # default: 'localhost'
mqtt_port = 1883 # default: 1883
mqtt_clientid = 'broadlink'
mqtt_username = ''
mqtt_password = ''
mqtt_topic_prefix = 'broadlink/'
mqtt_multiple_subprefix_format = 'broadlink/MP1_db_9a_b9/'
mqtt_multiple_subprefix_format = 'broadlink/A f9_0b_79/'
#mqtt_multiple_subprefix_format = '{type}
{mac_nic}/'

use only with 'multiple_lookup' device type (allowed parameters are {type}, {host}, {mac}, {mac_nic})

MQTT TLS parameters

Required with TLS: a string path to the Certificate Authority certificate files that are to be treated as trusted by this client.

ca_certs = '/path/to/ca_certsfile'

Optional Clients Cert/Key

certfile = '/path/to/certfile'

keyfile = '/path/to/keyfile'

Required TLS version. Valid values: 'sslv3', 'tlsv1', 'tlsv1.2'

tls_version = 'tlsv1.2'

extra parameters

broadlink_rm_temperature_interval = 120 # publish temperature from RM device to broadlink/temperature topic every two minutes
broadlink_sp_energy_interval = 30 # publish energy from SP device to broadlink/energy topic every 30 seconds
broadlink_a1_sensors_interval = 30 # publish all sensors data from A1 device to broadlink/sensors/[temperature/humidity/light/air_quality/noise] topics every 30 seconds
broadlink_a1_sensors_text_values = False # use True to send text representation of light/air quality/noise values
broadlink_a1_sensors_json = False # False to send every sensor parameter in separate topic, True - to send all together as JSON object
Do you have help me?
thanks so much
Revero11

Macros

Hi Eugene,

Further to the issue raised last week I have tried the change you suggested to no avail;

I am trying to create a macro for a two digit channel number, channel 10.

Item File;
Switch Broadlink_Samsung_10 {mqtt=">[broker:broadlink/channel_10:macro:*:replay]"}

Sitemap
Switch item=Broadlink_Samsung_10 label="ITV3"

File in Macros directory;
commands/tv/samsung/1
pause 250
commands/tv/samsung/0

I have tried with auto instead of replay but neither work

Thanks

Script doesn't work with broadlink 0.7 and above

I use your script in docker container and recently restarted it. As part of startup, it installs python libraries

pip install paho-mqtt broadlink

And as result the recent 0.8 version of broadlink. With this version, your script returns the error (i use rm device)

python mqtt.py
Traceback (most recent call last):
  File "mqtt.py", line 362, in <module>
    devices = get_device(cf)
  File "mqtt.py", line 250, in get_device
    device = broadlink.rm(host=host, mac=mac)
TypeError: __init__() takes exactly 4 arguments (3 given)

When installed 0.6 it started to work again

pip install broadlink==0.6

Please fix compatibility with the new version, or add dependency on the specific version. Thanks.

Constant MQTT disconnection

Hi,

After a reboot, every time I run the script I get the following output repeated every ten seconds:

[2017-03-13 23:01:20,010] DEBUG Connected to RM2 Broadlink device at ('192.168.0.3', 80)
[2017-03-13 23:01:20,014] DEBUG Connected to MQTT broker, subscribing to topic broadlink/#
[2017-03-13 23:01:20,015] DEBUG OOOOPS! Broadlink disconnects

Any ideas? I was trying to add it to systemd as a service, which worked, but also brought up these errors in its log.

do you mind give me a little help

Hi, your code works perfectly well as I want, I really dislike to have an android for bridge, this is really a brilliant work. thank you.

I am a newbie on linux and raspberry pi, I got a stupid question to ask, is there anyway that I may run your code on background and auto start when system start up? so I don't have to manually activate your code.

Thanks and Regards

More Codes if you want them

I have a harmony remote, their database includes individual buttons for hdmi1 - 4 etc. I've got those as code for the rm3 if you want.

Issue running two instances of mqtt.py

I can not seem to figure out what is causing this issue. I have created a copy of the broadlink-mqtt-master directory with a new name. I modified the conf file to be directed to the IP address and modified the mqtt topic. I still am getting the following error when I try to run the second instance.
Please let me know where I am going wrong.

Traceback (most recent call last):
File "mqtt.py", line 262, in
device = get_device(cf)
File "mqtt.py", line 202, in get_device
logging.error('More than one Broadlink device found (' + ', '.join([d.host for d in devices]) + ')')
TypeError: sequence item 0: expected string, tuple found**

How to send out signal /w decode error

Hi
I am new for the OpenHab, trying to setup my own system, I received the following message with decode error, any instruction will be appreciated....

**[error message]
DEBUG Received MQTT message broadlink/tv/samsung/power replay
[2019-10-20 21:02:49,972] DEBUG Replaying command from file C:\openHAB2\userdata\etc\scripts\broadlink-mqtt/commands/tv/samsung/power
[2019-10-20 21:02:49,975] ERROR Error
Traceback (most recent call last):
File "mqtt.py", line 198, in on_message
replay(device, file)
File "mqtt.py", line 303, in replay
device.send_data(ir_packet.strip().decode('hex'))
LookupError: 'hex' is not a text encoding; use codecs.decode() to handle arbitrary codecs
[2019-10-20 21:03:42,801] DEBUG Received MQTT message broadlink/tv/samsung/power 0

[.thing file]
Bridge mqtt:broker:mybroadlinkBroker [ host="localhost", secure=false ]
{
Thing topic BL "BL_P"
{
Channels:
Type string : TEP [
stateTopic="broadlink/temperature"]
Type switch : PowerSwitchBL [
commandTopic="broadlink/tv/samsung/power",
on="replay"]
}
}

[.item file]
String Switch_TEP "TEP [%s]" {channel="mqtt:broker:mybroadlinkBroker:BL:TEP"}
Switch PowerSwitchBL "SwitchBL" {channel="mqtt:broker:mybroadlinkBroker:BL:PowerSwitchBL"}

socket.error: [Errno 111] Connection refused

Hi,
I get the below error when I lunch mqtt.py.

[2018-05-20 10:54:14,535] DEBUG Connected to RM2 Broadlink device at '192.168.0.56' (MAC xx:xx:xx:xx:xx:xx)
Traceback (most recent call last):
File "mqtt.py", line 385, in
mqttc.connect(cf.get('mqtt_broker', 'localhost'), int(cf.get('mqtt_port', '1883')), 60)
File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 768, in connect
return self.reconnect()
File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 895, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python2.7/socket.py", line 575, in create_connection
raise err
socket.error: [Errno 111] Connection refused

How do i start recording rf signals?

Hi!
We're three CS students currently studying a IoT course.
For our project work our goal is to schedule 433mhz blinds and dimmers via an alarm-clock app that we're about to create.
We've got a broadlink rm pro which already work with our blinds via the ihc app and home assistant, however we want to be able control them from our own app and thought your library should be perfect for us.
This is our planned design:
Screen Shot 2019-12-06 at 12 15 55

On our raspberry pi we've edited the custom.conff file with the broadlinks' ip and mac address, and while running the mqtt.py script we get the following message:

[2019-12-06 12:08:29,725] DEBUG Connected to 'RM2' Broadlink device at '192.168.0.12' (MAC c8:f7:42:48:57:ae) and started listening for commands at MQTT topic having prefix 'broadlink/'

Is it in this terminal window we're supposed to write recordrf -> broadlink/blinds/down ?
When writing in this window nothing happens, and it just keeps publishing the broadlinks' temperature.

Sorry for a probably very stupid question, it feels like we've stumpled into the grown-ups area and are not worthy of your attention... :)

Regular crash

Hi I am regularly getting the following crash when replaying a 433MHz file:

[2017-04-14 11:25:20,636] ERROR Error
Traceback (most recent call last):
File "/home/pi/mqtt-py/mqtt.py", line 83, in on_message
replay(device, file)
File "/home/pi/mqtt-py/mqtt.py", line 141, in replay
device.send_data(ir_packet.decode('hex'))
File "/usr/local/lib/python2.7/dist-packages/broadlink/init.py", line 450, in send_data
self.send_packet(0x6a, packet)
File "/usr/local/lib/python2.7/dist-packages/broadlink/init.py", line 250, in send_packet
response = self.cs.recvfrom(1024)
timeout: timed out

Any suggestions?

Thanks

Multiple RM3 devices

How will this work? I've just bought a 2nd. But I corrently specify in the mqtt.cong the ip and mac address.

Is it possible to get 2 running?

Help !! Trying to use this script in Home Assistant

How can i record a command with a mqtt topic "broadlink/office/light1/" and payload on or off.
When i do this it does't work.

it works only with the topic "broadlink/office/light1/" without the payload.

I want to integrate with the home assistant and i need the payload_on: "ON" and payload_off: "OFF"

sorry my english!!!

great job

Record

Hello, I could connect to my rm broadlink and mqtt broker!!
[2018-06-29 12:23:57,227] DEBUG Connected to RM2 Broadlink device at '192.168.1.108' (MAC 78:0f:77:00:b6:34) [2018-06-29 12:23:58,289] DEBUG Connected to MQTT broker, subscribing to topic broadlink/#

Then, where must I send a record message like this? record -> broadlink/tv/samsung/power
in python shell?
I'm a beginner in python...

mini 3 show as Unknown

need some help to to add device type as unknown.
i try adding to define device list but still dont work.
i have more than one device on network other is RM2 which works fine

RecordRF not working

I have a Broadlink RM Pro+ that I'm trying to get working. I send "recordrf" to the MQTT channel and broadlink enters recording mode but never manages to capture the command. I am able to record RF with other applications (broadlink-mqtt-bridge and e-control), so I know broadlink and the RF device work. Is this feature working? Thanks.

[2019-08-08 06:29:11,414] DEBUG Recording RF command to file /opt/broadlink-mqtt/commands/rollershutter/2/up
[2019-08-08 06:29:11,414] DEBUG Learning RF Frequency, press and hold the button to learn...
[2019-08-08 06:29:32,773] WARNING RF Frequency not found```

Device recognised as unknown

Hi,
I have purchased this device:
https://www.bgelectrical.uk/smart-sockets

After a bit of digging, I found out that they use a broadlink chip:

https://community.home-assistant.io/t/uk-wifi-smart-socket-screwfix-testing/119995/5

So I though I would try using your broadlink-mqtt

Kind of works:

pi@piup:~/broadlink-mqtt $ pi@piup:~/broadlink-mqtt $ python mqtt.py
[2019-10-09 10:27:40,822] DEBUG Connected to 'Unknown' Broadlink device at '192.168.0.99' (MAC c8:f7:42:fc:e5:45) and started listening for commands at MQTT topic having prefix 'broadlink/'
[2019-10-09 10:27:40,834] DEBUG Connected to MQTT broker, subscribing to topic broadlink/#

So, it connects to the device but it is unknown
It has two sockets so I tried to force the config as an MP1 device. No dice
It tried as a single socket SP1 and then SP2. No dice

It connects, so there must be a way.
I have a spare device that I can send by post
I can also send debug logs or whatever is needed

Thanks

BG1 issues

Noob question how do I add broadlink-mqtt to MQTT and control the BG1 devices...

Many thanks in advance

Energy value

Hello, I'm using multiple_lookup with RM2 and SP2. I operate fine with both.
I have problem with the value of energy of SP2, because always inform "None" even when SP2 is on and connected with a tv on for example.

Thanks!

Hi, just a quick message to say thank you for this. I've been waiting for something I can run on my pi as the android bridge is just frustrating to have a 2nd device.

This was so easy to use and I now have all my remotes created in node red.

Thanks again

Which Pi?

Happy Feedback.
What model Pi can you use. My experiance.

Never fed back before but, if it helps others?, I had a few problems but got it working on Pi V1 but not reliably, it would very occasionally record an RF remote but it was no real use. Two Days Playing!!
I had tried on an old Pi2 that was doing DHCP and more, this had real issues with python 3, my bad, also struggled with leaning new stuff, again me!.

What I wanted to feedback, Starting with a Pi3 and the latest "raspbian-buster" image, it worked within 5 minutes of starting off. THANKS!

So is there a minimum Pi it should work on?
Wanted to put it on a Pi Zero W, should it be OK?
Maybe put the minimum in the requirements?

hi,

can you add exception at code for time out? so code can keep running once there is time out

[2017-02-26 18:00:37,667] DEBUG Sending RM temperature 19.8 to topic broadlink/temperature
[2017-02-26 18:04:37,851] DEBUG Sending RM temperature 19.6 to topic broadlink/temperature
[2017-02-26 18:08:38,792] ERROR Error
Traceback (most recent call last):
File "/home/pi/broadlink-mqtt/mqtt.py", line 197, in run
self.scheduler.run()
File "/usr/lib/python2.7/sched.py", line 117, in run
action(*argument)
File "/home/pi/broadlink-mqtt/mqtt.py", line 184, in broadlink_rm_temperature_timer
temperature = str(device.check_temperature())
File "/usr/local/lib/python2.7/dist-packages/broadlink-0.3-py2.7.egg/broadlink/init.py", line 569, in check_temperature
response = self.send_packet(0x6a, packet)
File "/usr/local/lib/python2.7/dist-packages/broadlink-0.3-py2.7.egg/broadlink/init.py", line 342, in send_packet
response = self.cs.recvfrom(1024)
timeout: timed out

Code than stopped here, but actually it still running on background
[20:00:45] pi@openHABianPi:~$ ps aux | grep mqtt
pi 8470 0.0 0.1 5888 1948 pts/2 S+ 20:00 0:00 grep --color=auto mqtt
pi 24833 0.0 1.0 25152 10524 pts/2 S 09:20 0:10 python /home/pi/broadlink-mqtt/mqtt.py

Initialization vector must be bytes

I must be doing something wrong here.

The application starts if I use the default configuration settings, but I get an error "ERROR No Broadlink device found". When I run tcpdump, I don't see any traffic on the interface.

If I change the default settings (for example, local_address = '192.168.15.109', which is the IP address of the machine running broadlink-mqtt), I get the below error:

Traceback (most recent call last): File "mqtt.py", line 419, in <module> devices = get_device(cf) File "mqtt.py", line 272, in get_device broadlink.discover(timeout=lookup_timeout, local_ip_address=local_address) File "/usr/local/lib/python2.7/dist-packages/broadlink/__init__.py", line 136, in discover dev = gendevice(devtype, host, mac) File "/usr/local/lib/python2.7/dist-packages/broadlink/__init__.py", line 61, in gendevice return device_class(host=host, mac=mac, devtype=devtype) File "/usr/local/lib/python2.7/dist-packages/broadlink/__init__.py", line 529, in __init__ device.__init__(self, host, mac, devtype) File "/usr/local/lib/python2.7/dist-packages/broadlink/__init__.py", line 171, in __init__ self.update_aes(key) File "/usr/local/lib/python2.7/dist-packages/broadlink/__init__.py", line 183, in update_aes_crypto self.aes = Cipher(algorithms.AES(key), modes.CBC(self.iv), File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/primitives/ciphers/modes.py", line 92, in __init__ raise TypeError("initialization_vector must be bytes") TypeError: initialization_vector must be bytes

What am I doing wrong?

socket.error: [Errno 111] Connection refused paho-mqtt

Privetstvuyu, Evgheniy!

Have tho following issue:

I have an mqtt-broker (Eclipse-mosquitto) and mqtt-client (paho-mqtt) installed at the same box, which is Raspberry Pi 3 B+.

Current behavior:
The client paho-mqtt ends with socket.error no.111. if my broker is unreachable (just did not started yet prior to the client).

Expected behavior:
Client should make attempts to reconnect until the broker not become active/reachable.

I have seen the similar issue at #38 but did not understood the solution yet.

  File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1071, in reconnect
    sock = self._create_socket_connection()
  File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 3522, in _create_socket_connection
    return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
  File "/usr/lib/python2.7/socket.py", line 575, in create_connection
    raise err
socket.error: [Errno 111] Connection refused

RM Pro Enhancement Request: act as RF receiver

Hi,

I have a RM Pro device and I need to use it as a RF receiver.
I have lots of RF devices (e.g. light switches, door sensors, fire detectors) that can only emit a fixed 433 MHz RF code but I do not have any device capable of receiving those codes. The RM Pro device however would do a very good job, as it could capture the codes and allow further processing via MQTT.
RM Pro has the "learning mode" function, so it is physically capable to receive RF codes.

Please consider adding this functionality as an option to the default "learning mode".

Thanks a lot!

Broadlink SC1

hello I think the idea is great! it would be possible to extend the project and although this module (Broadlink SC1) to integrate
Request for feedback
Thanks in advance

connect to specific device?

hi,

instead of using device discovery
devices = broadlink.discover(timeout=lookup_timeout)

can we use setdevice function like
device = broadlink.rm(host=("192.168.1.10",80), mac=bytearray.fromhex("b4 43 0d d1 00 00"))

thanks

Broadlink RM Plus RF Replay issue

I have the Broadlink RM plus and the ir side of things works fine. I am unable to capture RF through this app and that has been noted by others. I captured them through the e-control app and then dumped the codes with python script (Broadlink-e-control-db-dump) which decodes a .db file from the e-Control android app and saves all learnt codes from the app into text files. The codes generated by this when saved as files in the command section will not replay without throwing an error.

[2018-09-18 18:06:33,993] DEBUG Replaying command from file /home/plains203/broadlink-mqtt/commands/shutters/rm1chan1/down
[2018-09-18 18:06:34,014] ERROR Error
Traceback (most recent call last):
File "mqtt.py", line 132, in on_message
replay(device, file)
File "mqtt.py", line 190, in replay
device.send_data(ir_packet.decode('hex'))
File "/usr/lib/python2.7/encodings/hex_codec.py", line 42, in hex_decode
output = binascii.a2b_hex(input)
TypeError: Non-hexadecimal digit found

The contents of that file are as below.
b1000403070611060807090609060807080e100e09060906090708070806100e1007090609060807090d09070f07080e100e09060906100f0f0e110d110d100f10060807090608070906090d110d09060906090609061106080e0906100e10070807080e090610070807080708070807080e110d09060906090609060906100e1106080708070807080e09061007080e100e09060906100e100e100e100e100e10070807080708070807080e100e09060807090608071007080e0906100e10070807080e090610060907080708060906090e100e09060807080709060906100e1006090609060906090e09061006090e100e08070807100e100e100e100e100e10060906090609060906090e100e09060807080709061006090e0807100e10060906090e080710060906090609060906090e100e08070807080709060807100d1106090609060906090e08071006090d110e08060907100d110e0f0f100d110d11060906090609060807090d110e08060906090708061106090d0906110d11060906080e090611060906090609060906080e100e09060906090609060906100e1007090609060807090d09061106080e100e09060906100e100e110d100e100e11050907080708070807080e100e09060906090608071006090e0906100e10070807080e090610070807080708070807080e100e09060906080709060906100e1006090708070807080e09061007080e100e09060906100e100e100e100e100e10070806090708060906090e100e09060906090608071006090e0906100e10060906090e090610060907080609070806090e100e09060906090608070906100e1006090708060906090e08071006090e100e09060906100e100e100e100e100e10060906090609070807080e100e09060807090608071006090e0906100e10070806090e080710060907080708070807080e110d09060906090609060906100e1106080708070806090e09061007080e110d09060906100e100e100e110d110d10070906080709060807080e100e09060906090609070f07080e0906110d10070906080e090005dc00000000

British General Smart Plug-through socket adaptor 240V

Hi there

I have used your software to get the state of my British General Smart Plug-through socket adaptor 240V (here is the link https://www.diy.com/departments/british-general-smart-plug-through-socket-adaptor-240v/5050765176590_BQ.prd).

However, I am not able to find the command topic as such and cannot turn the socket on or off. Here are my logs:

[2019-12-28 23:56:44,753] DEBUG Connected to 'BG1' Broadlink device at '192.168.0.32' (MAC fd:29:96:42:f7:c8) and started listening for commands at MQTT topic having prefix 'broadlink/'
[2019-12-28 23:56:44,755] DEBUG Connected to MQTT broker, subscribing to topic broadlink/#
[2019-12-28 23:56:45,764] DEBUG Sending BG1 pwr '1' to topic 'broadlink/state/pwr'
[2019-12-28 23:56:45,765] DEBUG Sending BG1 maxworktime '0' to topic 'broadlink/state/maxworktime'
[2019-12-28 23:56:46,764] DEBUG Sending BG1 pwr '1' to topic 'broadlink/state/pwr'
[2019-12-28 23:56:46,765] DEBUG Sending BG1 maxworktime '0' to topic 'broadlink/state/maxworktime'
[2019-12-28 23:56:47,766] DEBUG Sending BG1 pwr '1' to topic 'broadlink/state/pwr'
[2019-12-28 23:56:47,767] DEBUG Sending BG1 maxworktime '0' to topic 'broadlink/state/maxworktime'
[2019-12-28 23:56:48,765] DEBUG Sending BG1 pwr '1' to topic 'broadlink/state/pwr'
[2019-12-28 23:56:48,765] DEBUG Sending BG1 maxworktime '0' to topic 'broadlink/state/maxworktime'
[2019-12-28 23:56:49,768] DEBUG Sending BG1 pwr '1' to topic 'broadlink/state/pwr'
[2019-12-28 23:56:49,770] DEBUG Sending BG1 maxworktime '0' to topic 'broadlink/state/maxworktime'
......
.........
............

Is this smart plug made by BG compatible with your software? If not can it be made compatible please?

Many thanks.

auto run on pi3

tryin to auto run on pi3 keep getting error ... can u help..?

Mapping a MQTT command to a Rollershutter Button

I have set up an item for Samsung TV Volume using the Rollershutter item type. The issue with this is that the commands only refer to channelup and channeldown. Therefore, when you assign channelup to a Rollershutter item type it will change the TV channel up whether you press the up button or the down button. In order to work around this I did the following;

Rollershutter Broadlink_Samsung_channel {mqtt=">[broker:broadlink/tv/samsung/channelup:command::auto],>[broker:broadlink/tv/samsung/channeldown:command::auto]"}

However, when I press either button now it firstly sends the TV up a channel and then immediately down a channel so you end up where you started.

Can anybody help here please?

[Errno 10061]

Hello,
I run mqtt.py with python and I receive this error. Can you help me?

[2018-06-25 17:14:31,868] DEBUG Connected to RM2 Broadlink device at '192.168.1.108' (MAC 78:0f:77:00:b6:34)

Traceback (most recent call last):
File "C:\Python27\broadlink-mqtt-master\mqtt.py", line 385, in
mqttc.connect(cf.get('mqtt_broker', 'localhost'), int(cf.get('mqtt_port', '1883')), 60)
File "C:\Python27\lib\site-packages\paho\mqtt\client.py", line 768, in connect
return self.reconnect()
File "C:\Python27\lib\site-packages\paho\mqtt\client.py", line 895, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "C:\Python27\lib\socket.py", line 575, in create_connection
raise err
error: [Errno 10061] No se puede establecer una conexión ya que el equipo de destino denegó expresamente dicha conexión

Run on startup

I am trying to have the mqtt.py run on startup. I added
python /home/openhabian/broadlink-mqtt/mqtt.py &
to rc.local, but it did not seem to trigger the script.

I also get errors when trying to execute mqtt.py from node red.
Traceback (most recent call last): File "mqtt.py", line 3, in <module> import paho.mqtt.client as paho # pip install paho-mqttImportError: No module named paho.mqtt.client

I assume that has to do with the way paho was installed and it can't find the module... but I haven't figured that out either. I am assuming they might be related.

Is it something simple I am missing?

button sequence/combo?

any idea how to effectively send series of button press in one go?
for example, to activate channel 123 on my tv, i have to send button 1, button 2, and button 3 in quick succession

thanks

Homebridge/HomeKit?

Can this work with Apple HomeKit or maybe something like homebridge? I've used another homebridge plugin for the RM Mini 3 but find MQTT is so much more reliable. Thanks.

No temperature data from RM Pro+

Hi, Thanks for this tool, it is excellent!

Only thing missing is the lack of temperature date from the RM Pro+, is this in the pipeline?

Cheers!

Newbie questions

This looks very promising, I have a unit on order :)

Can I control other Broadlink devices with your scripts? such as light switches etc?

Macros

Hi Eugene,

I have been trying to record a macro to allow me to have a two numbered television channel selected. However, to date I have been unsuccessful.

item file setting

Switch Broadlink_Samsung_10 {mqtt=">[broker:broadlink/channel_10:macros:*:auto]"}

Are you able to assist me?

Thanks

Could not open socket with RM Mini

Hello, I am using Python 2.7, also set the device_type to 'rm' and using the MAC and hostname lookup.

I have checked the port it's not used

#./mqtt.py
[2017-04-27 18:34:35,601] DEBUG Connected to RM2 Broadlink device at ('192.168.11.203', 80)
Traceback (most recent call last):
  File "./mqtt.py", line 237, in <module>
    mqttc.connect(cf.get('mqtt_broker', 'localhost'), int(cf.get('mqtt_port', '1883')), 60)
  File "/usr/lib/python2.7/site-packages/paho/mqtt/client.py", line 700, in connect
    return self.reconnect()
  File "/usr/lib/python2.7/site-packages/paho/mqtt/client.py", line 822, in reconnect
    sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
  File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 111] Connection refused

Any help please ?

can you retreive status of MP1 device?

as below command will let me know MP1 status, can you make MP1 like bg1 can Subscription to current state like below?

broadlink_mp1_state_interval=120

command work
devices[0].check_power()
{'s3': True, 's4': True, 's2': True, 's1': True}

I also found another issue, my RM pro set in another subnet, and rpi have vlan interface,
I am able to connect to RM pro by broadlink_cli or broadlink_discovery. but I am not able connect it by mqtt.py, I have set local ip under same subnet but still can't work.

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.