Linux.mqtt: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „ mosquitto_sub -t shellyhtg3-543204567354/status/humidity:0“) |
Root (Diskussion | Beiträge) |
||
| (13 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
== Geräte == | |||
=== Shelly Temperatur & Luftfeuchtigkeit === | |||
mosquitto_sub -t shellyhtg3-543204567354/status/humidity:0 | mosquitto_sub -t shellyhtg3-543204567354/status/humidity:0 | ||
mosquitto_sub -v -t shellyhtg3-543204567354/status/humidity:0 >>/var/log/mosquitto/humidity.log & | |||
=== Shelly Stromzähler === | |||
mosquitto_sub -t shellypmminig3-84fce638c62c/status/pm1:0 | |||
==== per RPC den Energy Verbrauch auslesen ==== | |||
http://192.168.115.115/rpc/Shelly.GetStatus | |||
http://192.168.115.115/rpc/KVS.List | |||
{ | |||
"ble":{}, | |||
"bthome":{ | |||
"errors":["observer_disabled"]}, | |||
"cloud":{"connected":true}, | |||
"mqtt":{"connected":false}, | |||
"pm1:0":{ | |||
"id":0, | |||
"voltage":237.4, | |||
"current":0.679, | |||
"apower":96.0 , | |||
"freq":50.0, | |||
"aenergy":{ | |||
"total":88939.057, // <b>88,939057 kWh</b> | |||
"by_minute": [1654.950,1654.950,1448.081], | |||
"minute_ts":1730759340}, | |||
"ret_aenergy":{"total":0.000,"by_minute":[0.000,0.000,0.000],"minute_ts":1730759340}}, | |||
"sys": { | |||
"mac":"84FCE638C62C", | |||
"restart_required":false, | |||
"time":"23:29", | |||
"unixtime":1730759397, | |||
"uptime":952959,"ram_size":260232,"ram_free":85864,"fs_size":1048576,"fs_free":606208,"cfg_rev":13,"kvs_rev":0,"schedule_rev":0,"webhook_rev":2,"avail able_updates":{},"reset_reason":3}, | |||
"wifi":{"sta_ip":"192.168.115.115","status":"got ip","ssid":"OrgaMon","rssi":-39}, | |||
"ws":{"connected":false}} | |||
* der Wert pm1:0:aenergy:total ist | |||
** Unsicher: nicht stromausfall fest, also wenn der Strom am Shelly ausfällt ist der Wert wieder "0" | |||
** Unsicher: ist Firmware-Update fest? | |||
** Unsicher: ist Gerät-Neustart fest? | |||
== mosquitto == | |||
# | |||
# a MQTT broker is a 24/7 message relay/örtöö for topics | |||
# it is not a database, the broker duplicates messages for all subscribers | |||
# you can ask if you get notified if a topic of your interest changes (="subscribe") | |||
# you can send out a message (="publish") so all subscribers get it | |||
# The Broker is not persistent so values from "missed" messages can not be retrieved | |||
# But, if a Client publish a value with a "retain"-Flag the Broker hold the value for a time | |||
# after the publish by system A, if a client system B is a bit late - still unconnected, in the moment subscribing | |||
# to a retained message, system B gets the last known value stored by the broker. System B so | |||
# must not wait for the next live value, wich maybe come in minutes or hours | |||
# | |||
* installation | |||
apt install mosquitto | |||
* /etc/mosquitto/mosquitto.conf erweitern: | |||
allow_anonymous false | |||
password_file /etc/mosquitto/passwd | |||
listener 1883 0.0.0.0 | |||
* user anlegen | |||
mosquitto_passwd -c -b /etc/mosquitto/passwd <i>user</i> <i>password</i> | |||
* neustart | |||
systemctl restart mosquitto | |||
Aktuelle Version vom 3. Juli 2026, 19:24 Uhr
Geräte
Shelly Temperatur & Luftfeuchtigkeit
mosquitto_sub -t shellyhtg3-543204567354/status/humidity:0 mosquitto_sub -v -t shellyhtg3-543204567354/status/humidity:0 >>/var/log/mosquitto/humidity.log &
Shelly Stromzähler
mosquitto_sub -t shellypmminig3-84fce638c62c/status/pm1:0
per RPC den Energy Verbrauch auslesen
http://192.168.115.115/rpc/Shelly.GetStatus http://192.168.115.115/rpc/KVS.List
{
"ble":{},
"bthome":{
"errors":["observer_disabled"]},
"cloud":{"connected":true},
"mqtt":{"connected":false},
"pm1:0":{
"id":0,
"voltage":237.4,
"current":0.679,
"apower":96.0 ,
"freq":50.0,
"aenergy":{
"total":88939.057, // 88,939057 kWh
"by_minute": [1654.950,1654.950,1448.081],
"minute_ts":1730759340},
"ret_aenergy":{"total":0.000,"by_minute":[0.000,0.000,0.000],"minute_ts":1730759340}},
"sys": {
"mac":"84FCE638C62C",
"restart_required":false,
"time":"23:29",
"unixtime":1730759397,
"uptime":952959,"ram_size":260232,"ram_free":85864,"fs_size":1048576,"fs_free":606208,"cfg_rev":13,"kvs_rev":0,"schedule_rev":0,"webhook_rev":2,"avail able_updates":{},"reset_reason":3},
"wifi":{"sta_ip":"192.168.115.115","status":"got ip","ssid":"OrgaMon","rssi":-39},
"ws":{"connected":false}}
- der Wert pm1:0:aenergy:total ist
- Unsicher: nicht stromausfall fest, also wenn der Strom am Shelly ausfällt ist der Wert wieder "0"
- Unsicher: ist Firmware-Update fest?
- Unsicher: ist Gerät-Neustart fest?
mosquitto
# # a MQTT broker is a 24/7 message relay/örtöö for topics # it is not a database, the broker duplicates messages for all subscribers # you can ask if you get notified if a topic of your interest changes (="subscribe") # you can send out a message (="publish") so all subscribers get it # The Broker is not persistent so values from "missed" messages can not be retrieved # But, if a Client publish a value with a "retain"-Flag the Broker hold the value for a time # after the publish by system A, if a client system B is a bit late - still unconnected, in the moment subscribing # to a retained message, system B gets the last known value stored by the broker. System B so # must not wait for the next live value, wich maybe come in minutes or hours #
- installation
apt install mosquitto
- /etc/mosquitto/mosquitto.conf erweitern:
allow_anonymous false password_file /etc/mosquitto/passwd listener 1883 0.0.0.0
- user anlegen
mosquitto_passwd -c -b /etc/mosquitto/passwd user password
- neustart
systemctl restart mosquitto