Hi sports fans, learning from
www.switchdoc.com/2021/02/mqtt-weatherrack2-weather/I added these two lines:
------------------------------
if (( sLine.find('F007TH') != -1) or ( sLine.find('F016TH') != -1)):
sys.stdout.write('WeatherSense Indoor T/H F016TH Found' + '\n')
sys.stdout.write('This is the raw data: ' + sLine + '\n')
mqtt_publish_single(sLine)
if (( sLine.find('FT0300') != -1) or ( sLine.find('FT020T') != -1)):
sys.stdout.write('WeatherSense WeatherRack2 FT020T found' + '\n')
sys.stdout.write('This is the raw data: ' + sLine + '\n')
mqtt_publish_single(sLine)-------------------------------------
I get this error:
------------------------------------
WeatherSense Indoor T/H F016TH Found
This is the raw data: {"time" : "2021-03-02 20:33:46", "model" : "SwitchDoc Labs F016TH Thermo-Hygrometer", "device" : 20, "modelnumber" : 5, "channel" : 1, "battery" : "OK", "temperature_F" : 69.200, "humidity" : 39, "mic" : "CRC"}
Traceback (most recent call last):
File "readWeatherSensors.py", line 74, in <module>
mqtt_publish_single(sLine)
NameError: name 'mqtt_publish_single' is not defined
--------------------------------------------------------------
I also added:
import json <========== ADDED
from paho.mqtt import publish <========== ADDED
Creadted config.json
what am I doing wrong?
readWeatherSensors.py (3.81 KB)