NorthernMan54 / homebridge-rtl

Homebridge Plugin for rtl_433 devices
MIT License
22 stars 10 forks source link

Installing on Raspberry Pi #9

Closed dankantor closed 3 years ago

dankantor commented 3 years ago

I am running Homebridge v1.1.7 on a Raspberry Pi with Raspbian GNU/Linux Buster (10). I am using the RTL-SDR dongle. I've installed the homebridge-rtl plugin. When I go to install rtl_433 using sudo apt-get install rtl-433 I get this message:

Building dependency tree       
Reading state information... Done
E: Unable to locate package rtl-433

Any idea why this is happening?

NorthernMan54 commented 3 years ago

Looks like the more recent raspbian versions may not include rtf_433 as an available package, you will need to build it unless you can find a package

dankantor commented 3 years ago

Got it. Thanks. My Linux skills are not much to speak of but seems like there are some good instructions.

dankantor commented 3 years ago

I ended up following the instructions here https://github.com/merbanan/rtl_433/blob/master/docs/BUILDING.md and got it to work.

Since I don't know what deviceId I need to put into the config, I started Homebridge in Debug mode. I see this which has a message for @NorthernMan54 :

Loaded plugin: homebridge-rtl@0.0.24
Plugin 'homebridge-rtl' tried to register with an incorrect plugin identifier: 'homebridge-rtl_433'. Please report this to the developer

I then see this:

[rtl_433] Initializing rtl_433 platform...
[rtl_433] Spawning rtl_433

But then there are no messages coming through. I have Acurite and LaCrosse temp sensors. Do I need to do anything else to see messages from them?

NorthernMan54 commented 3 years ago

Any other error messages ?

If not then you should start to see message.

One way to check is to just run rtl_433 outside of home bridge to make sure that you are in range of your devices.

dankantor commented 3 years ago

No other error messages. I tried running it outside of Homebridge and don't see anything. If I put my Acurite receiver next to the Raspberry Pi it shows full signal from the sensor.

rtl_433 version 20.11-45-gc359f71e branch master at 202101301302 inputs file rtl_tcp RTL-SDR
Use -h for usage help and see https://triq.org/ for documentation.
Trying conf file at "rtl_433.conf"...
Trying conf file at "/home/pi/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...
Registered 147 out of 177 device decoding protocols [ 1-4 8 11-12 15-17 19-21 23 25-26 29-36 38-60 63 67-71 73-100 102-105 108-116 119 121 124-128 130-149 151-161 163-168 170-175 177 ]
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to Auto.
Tuned to 433.920MHz.
Allocating 15 zero-copy buffers
NorthernMan54 commented 3 years ago

I'm not seeing a message from your Acurite temperature sensor there!

With acurite sensors, if you take out and put back the battery it emits a message within 30 seconds, and it should look similar to this

dankantor commented 3 years ago

I let it run overnight. In the morning I saw this error in the logs:

[rtl_433] ERROR: unknown device id - 89

In my Homebridge config I have this. Is there something different I should put?

{
  "platform": "rtl_433",
   "devices": []
}

Does it just scan for any and all devices that might be transmitting? I have not defined a device anywhere.

NorthernMan54 commented 3 years ago

Check the README, you need to configure each device in the config.json

dankantor commented 3 years ago

Yes but I first need the id of the device right? And the only way I know to get that is to instantiate the plug-in the way I did and then watch my logs running in debug mode. Am I missing something?

NorthernMan54 commented 3 years ago

You can determine the ID by just running rtl_433 outside of homebridge, and it will log the values. Then create the config.json entry, and your good to go

dankantor commented 3 years ago

Well I got it to work! Thank you for helping me track this down. It turns out the dongle is not very sensitive. I can only get readings when my sensor is a few inches from the dongle. The LaCrosse base receives the signal across the house.

Do you have an antenna hooked up to your dongle? Maybe it's possible my USB is underpowered as well.

Image from iOS

Screen Shot 2021-02-01 at 4 15 43 PM
NorthernMan54 commented 3 years ago

I use this model on a RPI 3 with house wide range. Is there an antenna option for yours?

5305671D-02B9-46D1-B8C4-1BBB32D6549C

PS Glad to hear you identified your issue

dankantor commented 3 years ago

Thanks for sharing. There is something similar for my dongle as well.

dankantor commented 3 years ago

I seem to have another issue. When I run rtl_433 -f 915M I see the correct temp for my device but in celsius. I then run rtl_433 -f 915M -C customary and see the temperature in Fahrenheit. But when I run this plugin in Homebridge it just shows 32 degrees. Not sure if that is F or C but it is not the correct temp regardless.

NorthernMan54 commented 3 years ago

Hummm, internally the plugin is running with this command line, and is expecting the input to be in Celsius

q -F json -C si

If you need a different command line you will need to change 'sensor.js' on line 58

Am thinking you need to add the -f 915M option

dankantor commented 3 years ago

Ah so it’s just running on 433 MHz? I have a couple of different devices - 433 and 915. Was wondering how it can listen on both at the same time. That’s not possible?

It would be nice if you can pass in params to rtl_433 in config.json. If you’d like I can open up a new issue for that.

dankantor commented 3 years ago

I changed line 58 to var proc = childProcess.spawn('pkill rtl_433;/usr/local/bin/rtl_433', ['-q', '-F', 'json', '-C', 'si', '-f', '950M'], { shell: true }); but I am still seeing 32 degrees. Not really seeing anything when I run Homebridge in DEBUG mode.

NorthernMan54 commented 3 years ago

Outside of homebridge you want to test the command line to ensure that you can see a json message, and that the temperature is coming thru in Celsius

Homebridge will display a wacky value until the first time it receives a message from sensor.

dankantor commented 3 years ago

Ok, I've got it working. Thanks for all your help! I switched back to my Acurite running at 433. I think the 915 LaCrosse sensor might be a bit broken after 10 good years of use. It looks like I'll need an antenna for the dongle as well. Once that's in place and I make sure it's range is good, I'll go buy a bunch of cheap Acurites to put around the house.

Thanks so much for such a wonderful project!

NorthernMan54 commented 3 years ago

Glad to hear, good luck