eschava / broadlink-mqtt

MQTT client to control BroadLink devices
MIT License
222 stars 60 forks source link

How do i start recording rf signals? #49

Closed dirtycoyote closed 4 years ago

dirtycoyote commented 4 years ago

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... :)

eschava commented 4 years ago

I'm glad you selected my project for your task :)

It was created to communicate with Broadlink devices using the MQTT protocol (https://en.wikipedia.org/wiki/MQTT) which is supported by the most home automation systems But it doesn't mean that broadlink-mqtt uses MQTT to communicate with Broadlink devices. Proprietary Broadlink protocol is used there and the underlying python-broadlink library implements all its details. So my project is just a gateway between MQTT broker and python-broadlink library

Is it in this terminal window we're supposed to write recordrf -> broadlink/blinds/down ?

No, the terminal window is read-only and just outputs the application log. You need to connect to the same MQTT broker using some MQTT client (developed by ourself or any other from Google Play market) and send "recordrf" command to the "broadlink/blinds/down" topic

Do not hesitate to ask any questions, I'm glad to help you (even though my English is very poor :)

dirtycoyote commented 4 years ago

Thank you so much!! We've opened a second terminal window and entered: mosquitto_pub -d -t broadlink -m "recordrf"

Now we get: [2019-12-06 13:00:35,735] DEBUG Received MQTT message broadlink recordrf [2019-12-06 13:00:35,736] DEBUG Recording RF command to file /home/pi/mqtt/broadlink-mqtt/commands/ [2019-12-06 13:00:35,738] DEBUG Learning RF Frequency, press and hold the button to learn... [2019-12-06 13:00:50,243] DEBUG Sending RM temperature 0.0 to topic broadlink/temperature [2019-12-06 13:00:56,891] WARNING RF Frequency not found

  1. We know that the broadlink is capable of receiving the RF signal hardware-wise since it's possible with the ihc app, what could be our issue here..?

  2. What is the purpose of the mqtt.py script sending RM temperature..?

  3. I saw that someone else had the same issue with recordrf and you recommended him to use python3, i thought i had python3 but when checking version with python -V in the terminal it tells me it's Python 2.7.16. I googled and was told to run mqtt.py with "python3" instead of "python" which then gives me this message: pi@raspberrypi:~/mqtt/broadlink-mqtt $ python3 mqtt.py Traceback (most recent call last): File "mqtt.py", line 4, in import broadlink # pip install broadlink ModuleNotFoundError: No module named 'broadlink'

What do you think could be our issue..? Once again, big thank you :)

eschava commented 4 years ago

Why "-t broadlink"? It should be -t broadlink/blinds/down

We know that the broadlink is capable of receiving the RF signal hardware-wise since it's possible with the ihc app, what could be our issue here..?

Actually I've never tried to use RF device because I do not have such one. So I've just copied and adapted sample code

What is the purpose of the mqtt.py script sending RM temperature..?

Because it can :) It is enabled with broadlink_rm_temperature_interval config parameter

I saw that someone else had the same issue with recordrf and you recommended him to use python3

You can try python3 but you need to reinstall all dependencies for it. E.g. using command pip3 install -r requirements.txt

dirtycoyote commented 4 years ago

I happy to tell you that we got it working now and with RF, thank you so much! It only works with python3, could be good to know for people in the future.

We've run into a new problem however with macros, we have created a file named blinds_up_morning and it contains:

blinds/up pause 5000 blinds/stop pause 5000 blinds/up pause 5000 blinds/stop pause 5000 blinds/up

we publish it like this:

mosquitto_pub -d -t broadlink/blinds_up_morning -m "macro"

but get this in respons:

[2019-12-11 11:18:12,901] DEBUG Replaying macro from file /home/pi/mqtt/broadlink-mqtt/macros/blinds_up_morning [2019-12-11 11:18:12,907] ERROR Error Traceback (most recent call last): File "mqtt.py", line 203, in on_message macro(device, file) File "mqtt.py", line 311, in macro line = line.strip(' \n\r\t') TypeError: a bytes-like object is required, not 'str'

Can you spot a mistake that we have done?

eschava commented 4 years ago

Thanks! Fixed the issue and docs