Smart Meter to MQTT post

289 views
Skip to first unread message

Philippe Borghini

unread,
Jan 17, 2021, 4:24:22 AM1/17/21
to TasmotaUsers
Hi

I am trying to create a tasmota script to read MODBUS KWh meter using tasmota sonoff device then publish the results on MQTT.

According numerous post I have read on the subject I can now listen the meter successfully according to following script:

>D
V1=0
>B

=>sensor53 r

>M 1

+1,3,M,1,9600,PAC,1,5,08040000,08040008,0C040008,0b040008,08040012,0C040012,0b040012

1,080404ffffffff@i0:1,L1 Voltage,V,Voltage_L1,2

1,080404ffffffff@i1:1,L1 Current,A,Current_L1,2

1,0C0404ffffffff@i2:1,L2 Current,A,Current_L2,2

1,0b0404ffffffff@i3:1,L3 Current,A,Current_L3,2

1,080404ffffffff@i4:1,L1 Power,W,Power_L1,2

1,0C0404ffffffff@i5:1,L2 Power,W,Power_L2,2

1,0b0404ffffffff@i6:1,L3 Power,W,Power_L3,2

1,=h=============

1,=m 2+3+4 @100,Current total,A,Current_tot,2

1,=m 5+6+7 @100,Power total,W,Power_tot,2

>T

V1=sml(1 1)

=>Publish emoncms/PAC/volt_L1 %V1%

#

Of course I recompile tasmota using following flag:

USE_SCRIPT USE_SML_M USE_RULES USE_RULES

I can read every teleperiod time the status 10 with all measurement but now I would like to publish the measurement only on a specific mqtt topic ex.
Topic:  emoncms/PAC/power_L1

But noway to pass the variable from “Smart Meter” bloc to MQTT

Hint are welcome

Philip Knowles

unread,
Jan 17, 2021, 4:52:07 AM1/17/21
to Philippe Borghini, TasmotaUsers

>J
The lines in this section are published via MQTT in a JSON payload on 
TelePeriodRequires compiling with #define USE_SCRIPT_JSON_EXPORT.

 

Sent from Mail for Windows 10

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/c51282c2-f08c-4139-8706-c5ae9ae85c86n%40googlegroups.com.

 

Philippe Borghini

unread,
Jan 17, 2021, 9:48:52 AM1/17/21
to TasmotaUsers
Thanks for the answer but what should I understand. Should I put some line in the >J context and recompile with  #define USE_SCRIPT_JSON_EXPORT ??
Thanks for clarification

Philip Knowles

unread,
Jan 17, 2021, 10:29:00 AM1/17/21
to Philippe Borghini, TasmotaUsers

There is also a section in the Alexa Controlled MCP230xx I2C GPIO Expander on the Scripting page where they publish over MQTT

=#pub

 

; publish routine

#pub

=>publish stat/%topic%/RESULT {"MCP23XX":{"p1":%0p1%,"p2":%0p2%,"p3":%0p3%,"p4":%0p4%}}

svars

 

Philippe Borghini

unread,
Jan 19, 2021, 11:48:39 AM1/19/21
to TasmotaUsers
Still not clear for me. I have tried several configuration without success.
Now my tasmota is recompiled with USE_SCRIPT_JSON_EXPORT flag
Then no way to publish in MQTT only the value of one of this line below:

1,080404ffffffff@i0:1,L1 Voltage,V,Voltage_L1,2

1,080404ffffffff@i1:1,L1 Current,A,Current_L1,2

1,0C0404ffffffff@i2:1,L2 Current,A,Current_L2,2

1,0b0404ffffffff@i3:1,L3 Current,A,Current_L3,2

1,080404ffffffff@i4:1,L1 Power,W,Power_L1,2

1,0C0404ffffffff@i5:1,L2 Power,W,Power_L2,2

1,0b0404ffffffff@i6:1,L3 Power,W,Power_L3,2


Reply all
Reply to author
Forward
0 new messages