Coder Social home page Coder Social logo

mverleun / rtl433-to-mqtt Goto Github PK

View Code? Open in Web Editor NEW
92.0 8.0 20.0 33 KB

Publish info from RTL433 receiver to MQTT broker

License: GNU General Public License v3.0

Python 64.95% Dockerfile 35.05%
mqtt-bridge rtlsdr rtl433 mqtt rtl-sdr python-script

rtl433-to-mqtt's People

Contributors

adamwhittingham avatar kpucynski avatar mverleun avatar panctronic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rtl433-to-mqtt's Issues

NameError: name 'subtopic' is not defined

Connecting with authentication
Starting RTL433
MQTT: Connected
Found Rafael Micro R820T tuner

Tuned to 433.920MHz.

Traceback (most recent call last):
File "./rtl2mqtt.py", line 97, in
subtopic += "/" + str(value)
NameError: name 'subtopic' is not defined

rtl_433 no longer receives messages

Hi there, hope someone can help me....
you can answer to me in English or German...

I used rtl_433 (version 18.12-262-g74b9a82) a few weeks an a Raspberry Pi3.

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

since two days I get any messages, when I start the program.

pi@raspi3:~ $ rtl_433 -G
rtl_433 version 18.12-262-g74b9a82 branch master at 201908151427 inputs file rtl_tcp RTL-SDR
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"...

Use -G for testing only. Enable protocols with -R if you really need them.


Consider using "-M newmodel" to transition to new model keys. This will become the default someday.
A table of changes and discussion is at https://github.com/merbanan/rtl_433/pull/986.

Registered 128 out of 134 device decoding protocols [ 1-4 6-8 10-17 19-26 29-64 67-134 ]
Found Fitipower FC0012 tuner
Exact sample rate is: 250000.000414 Hz
Sample rate set to 250000 S/s.
Tuner gain set to Auto.
Tuned to 433.920MHz.
Allocating 15 zero-copy buffers

after a minute or two I get this message:

pulse_FSK_detect(): Maximum number of pulses reached!

What does this message means ???

I know this dongle is not the best, but it worked a few weeks 24/7
the only problem with this device was it hangs up sometimes....
I get this message when it hungs up.

Async read stalled, exiting!

Question: what USB donges do you use with good Experience ?

I checked the USB DVB-T stick on a Win 7 computer using rtl_433, with the same result.
My first idea was that the reciever is broken, but with a SDR software it seems to work.
I also have a RTL.SDR.COM V.3 Device and tried this with rtl_433
(the RTL.SDR.COM V.3 works with a SDR software too)

I also tried with the RTL-SDR.com V3
hrere the result:

pi@raspi3:~ $ rtl_433 -G
rtl_433 version 18.12-262-g74b9a82 branch master at 201908151427 inputs file rtl_tcp RTL-SDR
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"...

Use -G for testing only. Enable protocols with -R if you really need them.


Consider using "-M newmodel" to transition to new model keys. This will become the default someday.
A table of changes and discussion is at https://github.com/merbanan/rtl_433/pull/986.

Registered 128 out of 134 device decoding protocols [ 1-4 6-8 10-17 19-26 29-64 67-134 ]
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

after 2-3 Minutes I get the same message:

pulse_FSK_detect(): Maximum number of pulses reached!

So I tried also with different 433 MHz antennas, so it isn't an antenna issue.
Does anyone have a good idea, what the problem could be ?
I think two broken devices are unlikely....
What options Do I have, to analize whats wrong ?

Kind regards, Daniel

State topic incorrect when item has names with 'id'

My weather station pushes an item with the name 'humidity'.
The check for 'id' to construct the mqtt topic becomes true in this case, so instead of using the actual ID field, the humidity value is appended. This is obviously not what we want :-)

errors when I try to run rt2qtt.py

Hi,

I tried to get the Python script working and try o set it up like the desription.
the rtl_433 module is installed and run as it should.
When I try to run the" rt2qtt.py" script with the program called "thony python IDE",
but I get the following errors:

maybe it could have to do with the path of the files.
I saved the in the folowing directory: /home/pi/RTL433-to-mqtt

Traceback (most recent call last):
File "/home/pi/RTL433-to-mqtt/src/rtl2mqtt.py", line 51, in
mqttc.connect(MQTT_HOST, MQTT_PORT, 60)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 839, in connect
return self.reconnect()
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 962, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python3.7/socket.py", line 727, in create_connection
raise err
File "/usr/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
OSError: [Errno 113] No route to host

PS, I'm just starting to use Python, so i'm a "newbie" in that.
thank you for helping me.

No data from 868Mhz weather station

I have a Alecto WS3100 weather station, which works on the 868Mhz band, and I'm trying to get data from it using this tool, but until now I'm unlucky and have not succeeded.

I have gotten the project to work and it runs without problems.
To make it work on the 868Mhz band I've made a little change in the python script, I've changed the rtl_433_cmd:
rtl_433_cmd = "/usr/local/bin/rtl_433 -f 868M -M level -s 1024k -F json"

When starting the program everything seems to start without a problem and it is scanning on the 868Mhz band:

Connecting with authentication
Starting RTL433
MQTT: Connected
Found Fitipower FC0012 tuner

Tuned to 868.000MHz.

But my MQTT server isn't receiving any data from this. Is there any way I can debug this or get more information on why no data is received?

Add id to model for unique device

Hi. First off, thanks! I got this up and running with zero problem and minimum effort. I have a bunch of water sensors that all show up as the same model but they all have unique ids. I'd like to be able to change the mqtt topic to include the additional id to the model name to make for unique messages.

I've tried adding this after the check if 'model' is in the JSON:

if "id" in item:
    subtopic=subtopic+ '-' + str(value)

but my python skills are obviously not up to par. Can someone tell me how to mod the script to make the devices unique? Thanks again!

Same sensor more than once available

I do have the same temp sensor three times.
{"time" : "2019-12-25 16:34:31", "model" : "Prologue sensor", "id" : 5, "rid" : 67, "channel" : 1, "battery" : "OK", "temperature_C" : 15.100, "button" : 0, "humidity" : 22}

{"time" : "2019-12-25 16:34:33", "model" : "Prologue sensor", "id" : 5, "rid" : 67, "channel" :3 , "battery" : "OK", "temperature_C" : 17.100, "button" : 0, "humidity" : 22}

{"time" : "2019-12-25 16:35:31", "model" : "Prologue sensor", "id" : 5, "rid" : 67, "channel" : 3, "battery" : "OK", "temperature_C" : 2.100, "button" : 0, "humidity" : 22}

the only difference here is the channel where I have 1,2 and 3. From your current parser, I can not see from which ID the temp came. It would be great to also have channel defined as a subtopic so I can see.

Can't get it to run

I have installed on my WIndows-10 computer a copy of rtl_433. I believe that this is working correctly, because it will correctly log data to a JSON file from the command:
.\rtl_433_64bit_static.exe -R 43 -F json:"D:\XPS_8700 Extended Files\Users\RowanB\Documents\Energy\Oil\Apollo Oil Level\Readings\oil_level_$((Get-Date).ToString("yyMMdd")).json"
I also have installed Mosquitto (Windows version). I also believe that this is working, but I don't really know how to test this.
Now I want to use rtl2mqtt to get rtl_433 to send its data to Mosquitto. I have changed the config.py file to this:

Config section

Fill in the next 2 lines if your MQTT server expected authentication

MQTT_USER="rowan.bradley"
MQTT_PASS="my_password"

MQTT_HOST="mqtt.example.com"

MQTT_HOST = "localhost"
MQTT_PORT=1883
MQTT_TOPIC="sensors/rtl_433"
MQTT_QOS=0
DEBUG=False # Change to True to log all MQTT messages

End config section

When I try to run rtl2mqtt using the command:
PS D:\XPS_8700 Extended Files\Users\RowanB\Downloads\RTL433-to-mqtt-master\src> .\rtl2mqtt

I get this:

Connecting with authentication
Starting RTL433
MQTT: Connected
Traceback (most recent call last):
File "D:\XPS_8700 Extended Files\Users\RowanB\Downloads\RTL433-to-mqtt-master\src\rtl2mqtt.py", line 72, in
rtl433_proc = subprocess.Popen(rtl_433_cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
File "C:\Program Files\Python310\lib\subprocess.py", line 966, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\Python310\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
PS D:\XPS_8700 Extended Files\Users\RowanB\Downloads\RTL433-to-mqtt-master\src>

Why is it giving me a file not found error? Which file is it that it can't find? How do I get this to run successfully?

Thank you - Rowan

crashes with message payload must be....

Hi, it runns nice but crashes shortly after starting sometimes.
the line number is much to high.
is this because the 433 delivered a broken data signal?
thank you!!

Tuned to 433.920MHz.

Traceback (most recent call last):
File "/home/pi/./rtl2mqtt.py", line 102, in
mqttc.publish(MQTT_TOPIC+"/"+subtopic+"/"+item, payload=value, qos=MQTT_QOS, retain=True)
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1247, in publish
raise TypeError(
TypeError: payload must be a string, bytearray, int, float or None.

[Comment] rtl_433's native MQTT support available

Hi Marco,
I'm a happy user of your RTL433-to-mqtt. So first: Many thanks for it ;-)

I guess your are aware of the recent addon of the direct MQTT publish feature of rtl_433:

output mqtt://..
or
-F mqtt ...

In combination with the MQTT format strings added a couple of weeks ago merbanan/rtl_433#1079 (comment) someone can achieve (almost?) the same topics published as done with your script, e.g.: merbanan/rtl_433#1079 (comment)

Curious to know, if you see still advantages of your script over the "direct" MQTT feature?
Did I miss something?

Error with multiple frequencies

You can use rtl_433 to search for devices in multiples frequencies, to do this you can provide an rtl_433.conf file with this example content:

frequency	868.3M
frequency	433.92M
hop_interval	60

With this example rtl_433 will be switching between the two frequencies every minute, allowing to detect more devices.
When the frequency switching ocurs, RTL433-to-mqtt fails in line 102 because the payload passed as value is a list:

File "rtl2mqtt.py", line 102, in <module>
     mqttc.publish(MQTT_TOPIC+"/"+subtopic+"/"+item, payload=value, qos=MQTT_QOS, retain=True)
   File "~/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1264, in publish
     'payload must be a string, bytearray, int, float or None.')

This error can be avoided by changing the line 101 from:

if not "model" in item:

to:

if (not "model" in item) and (type(value) is not list):

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.