-
Hi, Firstly thank you for the great work with TerrariumPi, I have for many years been using Node-Red on my home server remotely controlling my wifes Crested Gecko terrarium and was about to embark on a project to migrate it to one local controller and then I find TerrariumPi which is just perfect. So most sincerely thank you for a great project. I have set it all up on test and will shortly install the system. I do though have a question regarding MQTT. I have a central MQTT server which I use as common hub for all the different devices around the house and would like to broadcast the sensor values and relay states from TerrariumP but I am uncertain what I have to do in order to broacast the values every thirty seconds. I looked at an earlier thread discussing MQTT but it didn't really help. So, can you please tell me what I have to set in order to broadcast sensor and relay values once every thirty seconds? Many Thanks - Clive |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 13 replies
-
Hey Clive, I do something similar. I have a python script running on the
terrarium pi every minute that grabs data from the API
https://theyosh.github.io/TerrariumPI/api/
The script then pushes the data using mqtt to a central server.
I can share my script if that helps
Martyn
…On Wed, 11 May 2022, 15:04 G4KCM, ***@***.***> wrote:
Hi,
Firstly thank you for the great work with TerrariumPi, I have for many
years been using Node-Red on my home server remotely controlling my wifes
Crested Gecko terrarium and was about to embark on a project to migrate it
to one local controller and then I find TerrariumPi which is just perfect.
So most sincerely thank you for a great project.
I have set it all up on test and will shortly install the system. I do
though have a question regarding MQTT. I have a central MQTT server which I
use as common hub for all the different devices around the house and would
like to broadcast the sensor values and relay states from TerrariumP but I
am uncertain what I have to do in order to broacast the values every thirty
seconds. I looked at an earlier thread discussing MQTT but it didn't really
help.
So, can you please tell me what I have to set in order to broadcast sensor
and relay values once every thirty seconds?
Many Thanks - Clive
—
Reply to this email directly, view it on GitHub
<#702>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGVUFJOHVF6VRVWPL3VE7TVJO5AVANCNFSM5VVB464A>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
The idea is that you setup this in the notification area. There you can specify which services you want to use (MQTT) and what info you want to be sent to it. You can send a message every 30 seconds when a sensor is updated for example. |
Beta Was this translation helpful? Give feedback.
-
That sounds even easier
…On Wed, 11 May 2022, 17:36 TheYOSH, ***@***.***> wrote:
The idea is that you setup this in the notification area. There you can
specify which services you want to use (MQTT) and what info you want to be
sent to it. You can send a message every 30 seconds when a sensor is
updated for example.
—
Reply to this email directly, view it on GitHub
<#702 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGVUFNLWRFIHRJH4ANA47LVJPOZLANCNFSM5VVB464A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
It is not clear how to set it up though. All my mqtt messages are of
the form home/area/sensor = {data: value}. How is this done in
terrarium pi?
…On Wed, May 11 2022 at 09:36:37 -0700, TheYOSH ***@***.***> wrote:
The idea is that you setup this in the notification area. There you
can specify which services you want to use (MQTT) and what info you
want to be sent to it. You can send a message every 30 seconds when a
sensor is updated for example.
—
Reply to this email directly, view it on GitHub
<#702 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGVUFNLWRFIHRJH4ANA47LVJPOZLANCNFSM5VVB464A>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Here is my python script which runs as a cron job every minute. It is probably overkill and the notifications built in are probably better. #!/usr/bin/python3
# see https://github.com/alinleonard/LCD-I2C-Raspberry-Pi-2/blob/master/LCDI2C_backpack.py
# Import Libraries
import requests
import time
import paho.mqtt.client as mqtt
import json
def publishData(data):
client = mqtt.Client()
client.connect("192.168.86.22", 1883, 60)
client.publish("home/front_room/ds18b20/heater", json.dumps(data));
client.disconnect();
def main():
r = requests.get('http://localhost:8090/api/sensors/')
sensors = r.json()['data']
data = {}
for sensor in sensors:
if sensor['name'] == 'Main Temperature':
data['temperature'] = round(sensor['value'], 1)
if sensor['name'] == 'Cool Area':
pass
if sensor['name'] == 'Humidity':
pass
r = requests.get('http://localhost:8090/api/relays/')
switches = r.json()['data']
for switch in switches:
if switch['name'] == 'MPDMv4.1.3':
data['heater'] = switch['value']
publishData(data)
if __name__ == '__main__':
main() |
Beta Was this translation helpful? Give feedback.
-
I think you may have to restart the terrarium pi service to connect to the MQTT broker. Mine is now sending out messages. It seems that the topic is fixed in the code in the form: |
Beta Was this translation helpful? Give feedback.
-
I guess connecting to a MQTT server should not be a problem. Then I used the sensor update message: This will produce: The message will contain all the available data. And the custom message is available in the variable: The topics are fixed, as it will become to complex for the UI. And it does not work well with other notification services. |
Beta Was this translation helpful? Give feedback.
-
I also found that I need to restart after setting up the MQTT notification
in order for it to connect.
…On Wed, 11 May 2022, 22:13 TheYOSH, ***@***.***> wrote:
terrariumpi/sensor/update/848873668075f854bc07853fb386b4de
The last part is the ID of the sensor if you not already guessed..
—
Reply to this email directly, view it on GitHub
<#702 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGVUFO7I443IYNPB2OTUH3VJQPH3ANCNFSM5VVB464A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
I guess connecting to a MQTT server should not be a problem. Then I used the sensor update message:
This will produce:
The message will contain all the available data. And the custom message is available in the variable:
message
.The topics are fixed, as it will become to complex for the UI. And it does not work well with other notification services.