Hi @hafniumzinc ,
I may have found the reason why I couldn’t learn the RF codes, and I hope you might be able to assist me in solving it.
At one of the posts relating to “device storage is full” @eschava asked me this question:
“What is the value of the device_type parameter in the mqtt.conf or custom.conf files?”
His question made me realize I might have missed a step while trying to use the python-broadlink and broadlink-mqtt solutions you described in your guide.
In both solutions described in your guide, I did not fill my device_type parameters in any file.
For example, this is my device type output I got by using the python-broadlink method, but I didn’t notice I needed to save the device_type data into a special file located in the broadlink_cli folder.
pi@raspberrypi:~/python-broadlink/cli $ ./broadlink_discovery --timeout 10 --dst-ip 192.168.1.6
Discovering...
###########################################
RM4
# broadlink_cli --type 0x61a2 --host 192.168.1.6 --mac 24dfa7b9c689
Device file data (to be used with --device @filename in broadlink_cli) :
0x61a2 192.168.1.6 24dfa7b9c689
temperature = 0.0
I did the same mistake with the broadlink-mqtt solution. which means I didn’t fill my device type info into the custom.conf file.
It looks like the python-broadlink solution might be easier for noobs like me.
Could I trouble you, @hafniumzinc , to please explain how I should save the device_type info into the python-broadlink broadlink_cli folder, or to add the info into the custom.conf file under broadlink-mqtt?
The device_type parameter in mqtt.conf (or custom.conf) is by default set to lookup, which presumably means that broadlink-mqtt uses whatever python-broadlink discovers automatically as your device type. The extract you give:
Just wanted to let you know, that with the help of kind people on this thread I now know how to learn commands from RF remotes :))
To make a long story short, I was instructed to use this terminal command in order to start RF learning: python3 broadlink_cli --device "0x61a2 192.168.1.6 24dfa7b9c689" --rfscanlearn
Could it be the learn command you mentioned in your guide for the python-broadlink method was for IR learning only? devices[0].enter_learning()
I’ve been following the GitHub thread - well done on persevering, and they were very helpful!
What seems to have happened is that check_data() often produces the device storage is full error, and the python-broadlink project knows this.
As a result, they have added a try...except line for the check_data command in the broadlink_cli script, which basically ignores the device storage is full error if it appears, and carries on with the rest of the learning.
So it appears I need to update my tutorial to not use the low level commands from the python console, but just use the broadlink_cli script instead.
Possibly, I only have an IR remote! It looks like find_rf_packet() is the low level function, instead of enter_learning(), but I think the way you were instructed on the GitHub thread (using broadlink_cli) is what I’ll implement in the tutorial.
My steps are relevant for installation on Raspberry Pi OS.
I followed @hafniumzinc 's guide verbatim until the point of learning the RF codes.
When I tried learning the codes using the two methods @hafniumzinc mentioned (python-broadlink/broadlink-mqtt), both methods failed and returned the “device storage is full” message.
In that thread @felipediel suggested I use the following command in terminal from the /home/pi/python-broadlink/cli folder: python3 broadlink_cli --device "0x61a2 192.168.1.6 24dfa7b9c689" --rfscanlearn
This command allowed me to learn the RF codes and returned the codes in the terminal (make sure to fill-in your personal RMx device type, IP and MAC address).
After I got all my RF codes, I downloaded the latest broadlink binding jar file here, and copied it into OpenHAB’s addons folder /usr/share/openhab2/addons
Next, I followed this guide to install the Map Transformation in OpenHAB. To build my broadlink.map file, and copy it into the /etc/openhab2/transform folder. And lastly, to add the corresponding control buttons to my sitemap.
Thanks a lot for this guide @hafniumzinc!
It helped me indeed a lot. Just got an RM4C and integrated it with ease into my current mqtt boker.
I am able now to, at least via mqtt commands, control my TV and Xiaomi Mibox. Only got issues with my Samsung AC as somehow the hex codes are always different on each command (i.e. single on/off button push, hex codes is every time different).
Also need to continue integrating this into OH (for now only did the Mibox Power On/Off as example), hence need to think on how to translate i.e. volume up/down etc. into it.
Just want to thank @hafniumzinc for the tutorial; while I use the Broadlink binding rather than MQTT, his instructions, which augmented the python-broadlink docs and made them easier for a Python novice to understand, made it possible for me to use the library to learn the RF codes I needed to provide to the binding to control my ceiling fan via a new, updated RM4 Pro.
@hafniumzinc Really appreciated it if you can explain in detail step in the Configure OpenHAB until the Sitemap . i dont get what to do after create these 2 text files
bridge.things
I have a separate file which just contains the bridge Thing to my Mosquitto MQTT broker:
broadlink.things
bedroomfan.js
Saved into the transform folder:
I need to turn on/off my AC through Openhab 2(or 3) with hour schedule !
You don’t need a Sitemap to do this - you want to start looking at Rules. That’s all beyond the scope of this tutorial, but you might be able to do what you want just with the new UI in OH3.
I have to do it with a RM4 mini so this post is helpful so far but I’m stuck at Configure OH. I got the IR signal record via python-broadlink that i can replay it on python by your step :
This huge string is the code which needs to be saved. To double check that it works, you can send this code through python-broadlink back to your RM4C Mini device, and see whether it has the desired effect (switch things on/off etc):
>>> devices[0].send_data(packet)
>>>
We now need to save this huge string so that broadlink-mqtt can use it.
How do i put it together in Openhab and replay that signal through Mqtt topic to Rm4 to just turn the AC on and off ? I’ve setup the Mqtt Broker, Generic Mqtt Thing.