Hallo zusammen,
ich habe die letzten Wochen mal meinen Wemos D1 mit dem Script zum Laufen gebracht und habe auch versucht mit Tasmota einige Erfahrungen zu sammeln.
Dem Script habe ich MQTT-seitig nachgeholfen, indem ich folgendes als >B Sektion eingebaut habe:
>B
smlj=0 ;disable publishing at MQTT teleperiod, on boot
->sensor53 r
if mqtts>0
then
=#publish
endif
#publish
+>Subscribe V, tele/%Name des eigenen MQTT Gerätes%/SENSOR/sVolt, msg
+>Subscribe C, tele/%Name des eigenen MQTT Gerätes%/SENSOR/sCur, msg
+>Subscribe SW, tele/%Name des eigenen MQTT Gerätes%/SENSOR/sSwitch, msg
Dadurch habe ich den Workaround geschaffen, dass ich zumindest per MQTT Explorer z.B. im jeweiligen topic
Topic: tele/tasmota_owndevice/SENSOR/sVolt/
Message: {"msg":"12.00"}
Topic: tele/tasmota_owndevice/SENSOR/sCur/
Message: {"msg":"5.00"}
Topic: tele/tasmota_owndevice/SENSOR/sSwitch/
Message: {"msg":1}
alles soweit steuern kann. Mein Wissen zu mqtt und tasmota ist noch sehr begrenzt und mir ist bewusst, dass dies nicht die schöne Art ist, aber bislang das Beste, was ich so googeln konnte. Am Liebsten würde ich gerne in tasmota den DPM8624 als Device anlegen und per eigener Firmware als Device im Home Assistant auftreten lassen. Aber ich konnte leider weder so eine tasmota device Konfiguration finden, noch in HA irgendwelche Geräte, wo die Entitäten Inputfelder haben. Den Switch könnte man ja noch vielleicht hinbekommen, aber so schöne Eingabe- / StepUp- / StepDown- Felder wie auf der Weboberfläche?!
Egal. Ich hoffe, dass dies hier irgendjemand nützlich findet.
Da das komplette Script mit Änderungen zu groß ist, habe ich einige Kommentare gelöscht und komplett sieht es dann wie folgt aus (wobei der Name des MQTT-Devices noch angepasst werden muss)
>D
Vmax=60 ;
Cmax=24 ;
v=0 ;store device voltage state (targeted)
V=0 ;store WebUI voltage state (targeted)
c=0 ;store device current state (targeted)
C=0 ;store WebUI current state (targeted)
sw=0 ;store device switch state
SW=0 ;store WebUI switch state
rV="01060000" ;ModBus register (voltage)
vV="" ;store hex value of V to append to rV
rC="01060001" ;ModBus register (current)
vC="" ;store hex value of C to append to rC
rSW="01060002000" ;ModBus register (switch)
vSW="" ;store hex value of SW to append to rSW
>B
tper=60
smlj=0
->sensor53 r
if mqtts>0
then
=#publish
endif
#publish
+>Subscribe V, tele/%Name des eigenen MQTT Gerätes%/SENSOR/sVolt, msg
+>Subscribe C, tele/%Name des eigenen MQTT Gerätes%/SENSOR/sCur, msg
+>Subscribe SW, tele/%Name des eigenen MQTT Gerätes%/SENSOR/sSwitch, msg
>R
smlj=0
>S
if upsecs>3
then
smlj=1 ;re-enable publishing at MQTT teleperiod, after boot
endif
>W
bu(SW "DPM 8624 ON" "DPM 8624 OFF")
nm(0.0 60.0 0.01 V "DPM Ausgang (V)" 200 2)
nm(0.0 24.0 0.01 C "DPM Ausgang (A)" 200 2)
>T
sw=DC#sSwitch ;load switch state from ModBus variable >M
v=DC#sVolt ;load voltage state from ModBus variable >M
c=DC#sCur ;load voltage state from ModBus variable >M
if ((chg[sw]>0) and (SW!=sw)) ;update WebUI based on physical input (switch)
then
SW=sw
endif
if ((chg[v]>0) and (V!=v)) ;update WebUI based on physical input (voltage)
then
V=v
endif
if ((chg[c]>0) and (C!=c)) ;update WebUI based on physical input (current)
then
C=c
endif
if chg[V]>0 ;update ModBus register based on WebUI input (voltage)
then
if V>Vmax ;prevent out of bound value (voltage max)
then
V=Vmax
endif
if V<0 ;prevent out of bound value (voltage min)
then
V=0
endif
vV=rV+sb(hx((V*100)) 4 4)
sml(1 3 vV)
endif
if chg[C]>0 ;update ModBus register based on WebUI input (current)
then
if C>Cmax ;prevent out of bound value (current max)
then
C=Cmax ;prevent out of bound value (current min)
endif
if C<0
then
C=0
endif
vC=rC+sb(hx((C*1000)) 4 4)
sml(1 3 vC)
endif
if ((chg[SW]>0) and (sw!=SW) ;update ModBus register based on WebUI input (switch)
then
vSW=rSW+s(SW)
sml(1 3 vSW)
endif
>M 1
+1,4,m,16,9600,DC,5,2,010300000001,010300010001,010300020001,010310010001,010310020001,010310030001
1,010302SSssxxxx@i0:100,DC Spannung (set),V,sVolt,2
1,010302SSssxxxx@i1:1000,DC Strom (set),A,sCur,2
1,010302SSssxxxx@i2:1,Switch (set),,sSwitch,0
1,010302SSssxxxx@i3:100,DC Spannung (disp),V,dVolt,2
1,010302SSssxxxx@i4:1000,DC Strom (disp),A,dCur,2
1,010302SSssxxxx@i5:1,Temperatur,C,cTemp,1
#