Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 0x5f36 devices and RM4 series #317

Merged
merged 9 commits into from
Mar 16, 2020

Conversation

felipediel
Copy link
Collaborator

@felipediel felipediel commented Mar 5, 2020

These devices require a special header in the payload. The rest is the same.

Related issues:

RM 3 Mini (0x5f36)
#307
#308
home-assistant/core#30215
home-assistant/core#23566
lprhodes/homebridge-broadlink-rm#551

RM4 series
#301
#312

This type of device requires a header in the payload. The rest is the same.
@felipediel
Copy link
Collaborator Author

Please do not merge yet. I'm gonna do a final test.

I just found out that this device uses a different header for sending codes. This update addresses this issue.
@felipediel
Copy link
Collaborator Author

Everything is working now. This PR has been tested and is waiting to be merged.

Use the error code to check if the authentication was successful.
@ghost
Copy link

ghost commented Mar 6, 2020

This type of device requires a header in the payload. The rest is the same.

Related issues:
#307
#308
home-assistant/core#30215
home-assistant/core#23566
lprhodes/homebridge-broadlink-rm#551

ok but wich is the header?

@felipediel
Copy link
Collaborator Author

@marcol79 The header is here. But you don't have to worry about that. Once this PR is merged, your device will work out-of-the-box.

@ghost
Copy link

ghost commented Mar 6, 2020

@marcol79 The header is here. But you don't have to worry about that. Once this PR is merged, your device will work out-of-the-box.

ok so you advise me to wait?

@felipediel
Copy link
Collaborator Author

@marcol79 If you don't want to wait you can use this.

@ghost
Copy link

ghost commented Mar 7, 2020

@marcol79 If you don't want to wait you can use this.

I also wait because I have the bridge in openhab and I don't know which file to modify ;)

@ghedo
Copy link

ghedo commented Mar 7, 2020

FWIW I verified that this works, and I can now use the command-line tool's --learn and --send options with my 0x5f36 model. Nice work @felipediel! 🎉

Copy link
Collaborator Author

@felipediel felipediel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Danielhiversen This is something you might want to check out. How about we implement the discover function within our integration? We could do a single discover and share the results among our platforms.

broadlink/__init__.py Show resolved Hide resolved
I just realized that RM4 devices use the same header. I will take the opportunity to extend support to these devices as well.
@felipediel felipediel changed the title Add support for 0x5f36 devices Add support for 0x5f36 devices and RM4 series Mar 8, 2020
@felipediel
Copy link
Collaborator Author

@mjg59 @Danielhiversen Would you mind taking a quick look here? This PR solves all problems with the RM Mini3 0x5f36 and extends support to the entire RM4 series.

@felipediel
Copy link
Collaborator Author

Ah, an important information that we are missing is the last byte of HELLO_RESPONSE. If this byte is defined, the user will have to remove the device from Broadlink App and perform a procedure to disable the cloud. So I think it would be interesting to save this byte in some way so that the automation platforms can display an alert to the user with a link to a tutorial on how to perform the procedure.

@mjg59 @Danielhiversen What do you think about saving this byte? I can do this.

@felipediel
Copy link
Collaborator Author

dev = gendevice(devtype, host, mac)
devices.append(dev)
return devices

If we yield the devices instead of returning a list I can reduce our start up time in Home Assistant to less than 1 sec. But as we've changed a lot here, I'll leave that to a separate PR.

The rm4 class will improve code scalability. Just add the RM4 type to this class and it will just work.
@ArchGalileu
Copy link

Hello @felipediel

Great work hehhehehehehe

How can i adopt your solution?
Should i wait for the merge?

Best regards
ArchGalileu

@bblacey
Copy link

bblacey commented Mar 13, 2020

@ArchGalileu - you could do the following before it is merged:

# Clone the main repo and change working directory to repo
git clone https://github.com/mjg59/python-broadlink.git
cd python-broadlink

# Fetch and checkout Pull Request #317
git fetch origin pull/317/head:RM4
git checkout RM4

# Uninstall and re-install using pip
pip uninstall broadlink
pip install -e .

@felipediel
Copy link
Collaborator Author

@ArchGalileu You can also use:
pip install git+git://github.com/felipediel/python-broadlink.git@patch-1

If you are using Home Assistant, you also need to update the files I've changed in this PR. Download the files to your /custom_components/broadlink folder.

Detailed instructions here.

@sickrandir
Copy link

Hi @felipediel, I just want to let you know that I quickly tried your branch and it solved my issues with my RM 3 Mini (0x5f36). Awesome work! Hope it gets merged fast! Thanks a lot!!

@mjg59
Copy link
Owner

mjg59 commented Mar 16, 2020

Ah, an important information that we are missing is the last byte of HELLO_RESPONSE. If this byte is defined, the user will have to remove the device from Broadlink App and perform a procedure to disable the cloud. So I think it would be interesting to save this byte in some way so that the automation platforms can display an alert to the user with a link to a tutorial on how to perform the procedure.

Unfortunately I haven't been paying much attention to Broadlink stuff in a while - what's the backstory here? If the device sends this byte, it's enrolled in the cloud and can't be used locally, so the user needs to disable that? If so, setting that as a property in the device and letting the higher layers check that and prompt the user sounds like a good plan.

@mjg59
Copy link
Owner

mjg59 commented Mar 16, 2020

This looks pretty good to me - thank you for working on this! I'll wait to see if @Danielhiversen has any further feedback, but if not ping me in a week and I'll merge this.

@alefnode
Copy link

@ArchGalileu You can also use:
pip install git+git://github.com/felipediel/python-broadlink.git@patch-1

If you are using Home Assistant, you also need to update the files I've changed in this PR. Download the files to your /custom_components/broadlink folder.

Detailed instructions here.

Awesome, working perfectly

@Danielhiversen Danielhiversen merged commit 1a1169f into mjg59:master Mar 16, 2020
@felipediel
Copy link
Collaborator Author

Thanks for approving! 👍

@fizulnizam
Copy link

Anyone can help me with 5f36 on Homebridge?.. I am having the same issue with the 5f36 RM Mini 3 as well..

@Spanishu
Copy link

@felipediel is there any chance that you can apply your magic as well to the homebridge plugin https://github.com/lprhodes/homebridge-broadlink-rm
It would be much appreciated

@fizulnizam
Copy link

@felipediel please lend us your magic 🥺🙏

@torbenrockstar
Copy link

@felipediel would also appreciate if you could help on the homebdrige-broadlink-rm

would also pay for it :)

@Spanishu
Copy link

Spanishu commented May 1, 2020

@torbenrockstar have you checked here lprhodes/homebridge-broadlink-rm#600 it works like a charm

@torbenrockstar
Copy link

@Spanishu wow thank you very much, why havent i seen this. Spent the whole day implementing the changes from here by myself (actually just got the sendcode to work when your wrote this comment)

@felipediel
Copy link
Collaborator Author

Hi guys. I'm sorry I couldn't help you in time. I'm glad to know that @rafaelncarvalho managed to adapt the code. Now you can extend support to the entire RM4 series using those same headers.

@Dmitriy-sc
Copy link

Hi. I added support for the RM4 series in the plugin homebdrige-broadlink-rm, but RM4c Mini does not learn or send code.

// RM Devices (without RF support)
const rmDeviceTypes = {};
rmDeviceTypes[parseInt(0x2737, 16)] = "Broadlink RM Mini";
rmDeviceTypes[parseInt(0x27c7, 16)] = 'Broadlink RM Mini 3 A';
rmDeviceTypes[parseInt(0x27c2, 16)] = "Broadlink RM Mini 3 B";
rmDeviceTypes[parseInt(0x27de, 16)] = "Broadlink RM Mini 3 C";
rmDeviceTypes[parseInt(0x5f36, 16)] = "Broadlink RM Mini 3 D";
rmDeviceTypes[parseInt(0x273d, 16)] = 'Broadlink RM Pro Phicomm';
rmDeviceTypes[parseInt(0x2712, 16)] = 'Broadlink RM2';
rmDeviceTypes[parseInt(0x2783, 16)] = 'Broadlink RM2 Home Plus';
rmDeviceTypes[parseInt(0x277c, 16)] = 'Broadlink RM2 Home Plus GDT';
rmDeviceTypes[parseInt(0x278f, 16)] = 'Broadlink RM Mini Shate';
rmDeviceTypes[parseInt(0x6070, 16)] = 'Broadlink RM4c Mini';
rmDeviceTypes[parseInt(0x610e, 16)] = 'Broadlink RM4 Mini';
rmDeviceTypes[parseInt(0x51da, 16)] = 'Broadlink RM4 Mini';
rmDeviceTypes[parseInt(0x62bc, 16)] = 'Broadlink RM4 Mini';

Did I add correctly?

@felipediel
Copy link
Collaborator Author

@Dmitriy-sc It's not that simple. Follow this thread.

@Dmitriy-sc
Copy link

I did as indicated in this thread:

  • i added support for the entire RM4 series in the index.js
  • just replace the index.js from broadlinkrm-js.
  • After that, success: Discovered Broadlink RM at 192.168.1.20 (a7:df:24:34:5b:7f)

However, the learn code functionality doesn't seem to be working. Вut RM4c Mini does not learn or send code...

Maybe part of the code is missing in the index.js ?

@felipediel
Copy link
Collaborator Author

felipediel commented May 4, 2020

@Dmitriy-sc Did you copy all the file? Did you disconnect your device from the cloud? Did you adapt lines 245 and 246?

@Dmitriy-sc
Copy link

@felipediel, thank you very much. I did not know about the adaptation of lines 245-246. It works now.
And how to do so as not to change these lines for each PM4 device? If there will be two different: rm4pro and rm4c mini?

@felipediel
Copy link
Collaborator Author

@Dmitriy-sc I think the best approach is to use inheritance and interface segregation as we did in this library. If you adopt these design patterns your library will become more flexible to integrate new devices in the future.

@vitaliy-kozlov
Copy link

Hi, Thanks a lot for your work. Hoping RM4 will work soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.