Hallo,
im Anhang findet ihr ein python script welches die Daten des wp6003 per mqtt nach fhem sendet.
Als Parameter werden die Bluetooth Adresse und eine unique ID übergeben.
Im script ist die ip adresse des fhem Servers anzupassen.
Dann noch einen einen cron job einrichten.
# cat WP6003_1
*/5 * * * * root /opt/fhem/contrib/wp6003-mqtt.py 11:22:33:44:55:66 1
Hier der Auszug aus der fhem.cfg
define mqttBroker MQTT2_SERVER 1883 global
attr mqttBroker autocreate no
define MQTT2_WP6003_1 MQTT2_DEVICE WP6003_1
attr MQTT2_WP6003_1 IODev mqttBroker
attr MQTT2_WP6003_1 readingList WP6003_1:sensor/temperature:.* temperature\
WP6003_1:sensor/CO2:.* CO2\
WP6003_1:sensor/HCHO:.* HCHO\
WP6003_1:sensor/TVOC:.* TVOC\
WP6003_1:sensor/state:.* state\
WP6003_1:sensor/address:.* address
define FileLog_MQTT2_WP6003_1 FileLog /opt/fhem/log/MQTT2_WP6003_1-%Y-%m.log MQTT2_WP6003_1
attr FileLog_MQTT2_WP6003_1 logtype text
attr FileLog_MQTT2_WP6003_1 room Log Files
define weblink_WP6003_1 SVG FileLog_MQTT2_WP6003_1:wp6003:CURRENT
attr weblink_WP6003_1 label "Kohlendioxid WP6003_1 " . $data{currval1} ." ppm"
attr weblink_WP6003_1 plotsize 800,240
attr weblink_WP6003_1 room MQTT2_DEVICE,Plots
und dann noch das gplot file wp6003.gplot
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time
set timefmt "%Y-%m-%d_%H:%M:%S"
set xlabel " "
set ytics
set title '<L1>'
set grid xtics ytics
set ylabel "CO2 in c/ppm"
set y2label "Temperatur in °C"
#FileLog 4:CO2:0:
#FileLog 4:temperature:0:
plot "<IN>" using 1:2 axes x1y1 title 'CO2' ls l2 lw 1 with lines, \
"<IN>" using 1:2 axes x1y2 title 'Temperatur' ls l0 lw 1 with lines
Das script ist mehr oder weniger mein erstes python script.
Wäre schön, wenn sich das jemand anschaut, der mehr Ahnung von python hat als ich.
Folgende python Module musste ich nach installieren:
bleak
dbus_next
txdbus
paho-mqtt
Viel Spass damit,
Jörg