mverleun / RTL433-to-mqtt

Publish info from RTL433 receiver to MQTT broker
GNU General Public License v3.0
94 stars 20 forks source link

Error with multiple frequencies #12

Open davrodfer opened 3 years ago

davrodfer commented 3 years ago

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):