kiwi-cam / homebridge-broadlink-rm

[This fork supports TV accessories] Broadlink RM Mini and Pro plugin for homebridge: https://github.com/nfarina/homebridge
Apache License 2.0
302 stars 96 forks source link

Support for 315 MHz RF Devices #387

Closed hunterparks closed 1 year ago

hunterparks commented 3 years ago

Describe the bug When attempting to scan for RF devices, I am unable to get any data from a 315 MHz remote. The RF scanning works flawlessly for 433 MHz remotes, however.

To Reproduce

  1. Use RF leaning button
  2. Hold down RF button on remote
  3. 60 second timeout occurs

Expected behavior With the Broadlink RM4 Pro that I have with both 315 MHz and 433 MHz radios, I would expect to be able to learn and control devices in both frequency ranges.

Screenshots N/A

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context N/A

SergeyFIL commented 3 years ago

same problem!

it's ok even with 434 Mhz, 315 Mhz is not able to be learned

cspix commented 2 years ago

I have the same issue. RF signals on the 315 Mhz band are not getting picked up by the this plugin. They are getting picked up by the Broadlink app when specifying to scan on the 315 Mhz band.

cspix commented 2 years ago

Looking at the code it might be because the timeout is too short between frequency lookup? 1000ms?

hunterparks commented 2 years ago

Which file are you looking at?

cspix commented 2 years ago

learnRFData.js

I'm no engineer, just a graphic technical artist working usually in Python so I might not get the whole idea. That being said, I just tested with my 315 Mhz garage door opener and kept pressing the button on it without success. It does go into device.enterRFSweep() as the Broadlink light turns amber.

This is what my log outputs:

[INFO] Scan RF (scanning) [ACTION] Hold down the button that sends the RF frequency. [INFO] Scan RF (stopped - 60s timeout)

The amber light stays on about 30-40 seconds, before the 60s timeout.

kiwi-cam commented 2 years ago

If you're comfortable with Python you could always use this project to learn the codes: https://github.com/mjg59/python-broadlink. They use the same format(s) we save them in so you can just copy/paste them into your config.

cspix commented 2 years ago

Even using Python it doesn't pick up the code. Maybe I'm using this wrong? Very crude Python code below just to test.

import broadlink
import time

device = broadlink.hello('192.168.1.22')
device.auth()

device.sweep_frequency()
time.sleep(5)

device.find_rf_packet()
packet = device.check_data()

>> broadlink.exceptions.StorageError: [Errno -5] The device storage is full
cspix commented 2 years ago

What is the difference between sweep_frequency() and find_rf_packet()? How do they work together? Is there a different "check_frequency" code for the 315 and 433 Mhz band?

MM1969MM commented 2 years ago

Hi, same here from my side. While The Broadlink App is able to get the remote signal, the plugin won't. Any idea on how to obtain the required hex code anyways? When I use the learn feature from the AppleHome it runs into timeout even though the broadlink is showing his amber light.

I would really much appreciate if there is a fix :-)

Thanks for the plugin kiwi-cam. great job! Best regards ans stay safe Michael

chasenicholl commented 2 years ago

Edit* This plugin supports actions on other frequencies. It just doesn’t support finding hex codes from other frequencies.

If someone is still looking for a way to find hex codes for different frequencies I found a solution using a fork of the above mentioned python package. This works by the way to find the hex codes for my fireplace which uses 305MHz.

1.) uninstall python-broadlink if you already have it installed. 2.) clone this fork: https://github.com/DarkStarSword/python-broadlink/tree/dev Note* use dev branch. 3.) in the root directory run python setup.py install to install this version. 4.) run my little script (sorry not the prettiest but works) while holding the button down you wish to learn. Eventually it'll nab it and print it to your console. (This assumes Python >=3.7).

import argparse
import time

import broadlink

def main(ip_address: str, frequency: float) -> None:
    timeout = 60
    device = broadlink.hello(ip_address)
    device.auth()
    print("Sweeping frequencies...")
    device.sweep_frequency()
    time.sleep(2)
    device.find_rf_packet(frequency=frequency)
    time.sleep(2)
    search = True
    tick = 0
    while search:
        if tick == timeout:
            device.cancel_sweep_frequency()
            break
        try:
            print(device.check_data().hex())
            search = False
        except KeyboardInterrupt:
            print("Cancel Sweep Frequency")
            device.cancel_sweep_frequency()
            search = False
        except broadlink.exceptions.StorageError:
            print("Storage full error trying again...")
        time.sleep(1)
        tick += 1
    device.cancel_sweep_frequency()

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("ip_address")
    parser.add_argument("--frequency", nargs="?", type=float, const=433.92)
    args = parser.parse_args()
    main(ip_address=args.ip_address, frequency=args.frequency)
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

siangloon commented 2 years ago

I had same problem learning the RF signal until I pressed and released several time when the instruction is asking me to hold it.

kylewhirl commented 2 years ago

I am still having this problem. Is there any known solution?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

aw-0 commented 2 years ago

Bumping this issue, have tried many workarounds but still unable to pair a 315mhz device.

n8stowell82 commented 2 years ago

bumping this again as this is a huge issue preventing the use of this tool with HomeKit

kiwi-cam commented 2 years ago

I've added some notes on this issue to the documentation: https://broadlink.kiwicam.nz/#RFScanIssue. Hopefully it helps people out till we can get this sorted.

peditx commented 2 years ago

same

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

chasenicholl commented 1 year ago

@kiwi-cam I had to add a new RF device recently and came up with a better solution to learning frequencies. I hope this helps everyone. It's been a reproducible process for myself. I was able to easily learn a device that broadcasted on 318.000MHz.

  1. Install broadlink python library $ pip install broadlink
  2. Manually download the libraries CLI files a. optionally move these files into your $PATH, or just execute from where ever the files are located.
  3. Find your devices address in the SUPPORTED_TYPES constant. You may need to try different addresses.
  4. Run this command to start the process. Read below before running command. $ ./broadlink_cli --device "0xNNNN LOCAL_IP_ADDRESS MAC_ADDRESS" --rfscanlearn a. Long press your RF device button you'd like to learn b. Wait for prompt in your console to continue c. SHORT press the RF device button again d. Marvel in your HEX code appear in your console