Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
app-notes:ein-mqtt-server-fuer-iot-telemetry-sensoren [2023/11/09 14:46] – [5. Pass on information from the MQTT network to a free messenger.] grayapp-notes:ein-mqtt-server-fuer-iot-telemetry-sensoren [2023/11/09 15:08] – [4. The visualization of the telemetry data with the help of Grafana] gray
Line 356: Line 356:
 ===== - Bring data from the MQTT broker structured into a database ===== ===== - Bring data from the MQTT broker structured into a database =====
  
-Create an influx database via the console and add a user for access. +An Influx database is created via the console. Only the access and the name of the thank you bank need to be stored. A Python script retrieves the data from the MQTT broker and also builds the structure based on the data.
- +
-The structure in the database is then created with a Python script, using a Json format. +
- +
-<code c > +
-   json_body = [ +
-        { +
-            'measurement': sensor_data.measurement, +
-            'tags':+
-                'location': sensor_data.location +
-            }, +
-            'fields':+
-                'value': sensor_data.value +
-            } +
-        } +
-    ] +
-    influxdb_client.write_points(json_body) +
-</code> +
- +
  
 ---- ----
- 
- 
-With the help of the Python script, you can specifically query data from the broker and store it in the database in a structured way. 
  
 <code c shellyplusht subscribe_datenbank.py> <code c shellyplusht subscribe_datenbank.py>
Line 516: Line 495:
 ----   ----  
  
-The Python scripts are started and monitored via a cronjob. +A cronjob starts the Python script and monitors whether it is still running.
- +
-<konsole> +
- +
-# Das Skript wird alle 1 Minuten plus 20 sekunden gestartet +
-* * * * * sleep 20; /home/korris/plus_ht.sh +
- +
-</konsole> +
- +
-The script checks if the process is still running. If it is, it does nothing. If the process was terminated it is started again. The Python scripts run endlessly. The cronjob only checks if they are still running.+
  
 <konsole> <konsole>
Line 560: Line 530:
 From now on you have access to the data that is already in the database and that will be added over time. From now on you have access to the data that is already in the database and that will be added over time.
  
-Which measurements have been deposited in the database: 
- 
-<konsole> 
-:~ $ influx 
-Connected to http://localhost:8086 version 1.8.10 
-InfluxDB shell version: 1.8.10 
-:> use Shelly 
-Using database Shelly 
-:> show series 
-key 
---- 
-power,location=shellyplug-s-C8C9A3B8E8C6 
-rh,location=shelly-08b61fcf3380 
-tC,location=shelly-08b61fcf3380 
-tC,location=shellydw2-73BBC6 
-tC,location=shellyflood-244CAB430495 
-temperatur,location=shellyplug-s-80646F81A273 
-temperatur,location=shellyplug-s-80646F81AD26 
-temperatur,location=shellyplug-s-80646F81F06B 
-temperatur,location=shellyplug-s-C8C9A3A4DE17 
-value,location=shellydw2-73BBC6 
-value,location=shellyflood-244CAB430495 
-voltage,location=shellydw2-73BBC6 
-voltage,location=shellyflood-244CAB430495 
-</konsole> 
  
 ==== - The first visualization under Grafana ==== ==== - The first visualization under Grafana ====
Line 608: Line 553:
  
 With this function Grafana Discover I would try more function under the programs. One comes here quickly on solutions that are helpful in the implementation in the dashboard. With this function Grafana Discover I would try more function under the programs. One comes here quickly on solutions that are helpful in the implementation in the dashboard.
- 
-If one is then with the conversion for a dashboard, one can fall back on information here. 
- 
-{{:configuration:configuration:granfana_dashboard.png|}} 
  
 ---- ----