Thanks. I now have a temp sensor in the garage and one in the upright freezer. They are connected to RPi zero w’s and working great. Transmitting the data to HA via mqtt.
I am getting this error, any ideas how to correct.
pi@Garpi:~ $ ./tempmqtt.py
Traceback (most recent call last):
File “./tempmqtt.py”, line 14, in
os.system(‘modprobe w1-gpio’) # Turns on the GPIO module
NameError: name ‘os’ is not defined
Sorry for replying late. Just saw your message. Am not getting those notifications anymore from Home Assistant ever since I’ve modified my email address…
Haven’t you forgotten " import os" in your code?
hi @barbarin
is it possible to save the values from the subscribe topic onto a text file? how can I achieve that?
Thanks.
hi @bachoo786,
Anything is possible I suppose. You mean you want the python script to send the data to your broker and also save it to a text file?
Thanks for your example, exactly what I was trying to accomplish.
I am having troubles though, the values for the PIR are coming through and I have created a senor with an automation that works, but the logs in Mosquitto broker keep showing the below. I can’t figure out how to get it to stop. Also there is no new device or entity that was auto created.
1604997199: New client connected from 192.168.1.9 as auto-BD02EDE6-0D9C-004C-9535-592F16EA2096 (p2, c1, k60, u'mqtt').
1604997199: Client auto-BD02EDE6-0D9C-004C-9535-592F16EA2096 disconnected.
1604997300: New connection from 192.168.1.9 on port 1883.
1604997300: Socket error on client <unknown>, disconnectin
I think I worked out why it was throwing the errors.
I changed the initial connection to;
#MQTT
client = mqtt.Client()
client.username_pw_set('username', 'password')
client.connect(broker)
client.loop_start()
Im new with mqtt so i dont quite understand why it doesn’t show up as an entity or device under mqtt