Sinotimer WDS688 or ZMAi-90 Communication with Tasmota and OpenHAB2

Hi All,
i’m Angelo from Italy and this is my first post. In these quarantine days, i had time to work on a project that i left there for weeks.
I bought a SinoTimer WDS688 power meter to measure the voltage and the power of my main line with the “Smart Life” App. Then, after some weeks i decided to move completely to OpenHAB and i decided to try to convert this device to be used with this smart home system.

I based all my job on this already made project https://www.creationfactory.co/2019/12/reverse-engineering-zmai-90-din-rail.html

I just modify a little bit the rule inside the tasmota webpage and i created the rule in OpenHAB to parse the string that the WDS688 send back to the MQTT.

All the procedure you can follow on the original webpage.
I only modify the rule in the tasmota from the original:

Rule1 on System#Boot do RuleTimer1 10 endon on Rules#Timer=1 do backlog SerialSend5 fe010f080000001c; RuleTimer1 10 endon

to my modify:

Rule1 on System#Boot do Baudrate 9600 endon on System#Boot do RuleTimer1 2 endon on Rules#Timer=1 do backlog SerialSend5 fe010f080000001c; RuleTimer1 2 endon

I did this modify to reduce the delay from 10 seconds to 2 seconds for every measurements and also to set the Baudrate every startup of tasmota, otherwise it doesn’t work.

Then, inside OpenHAB i created the Thing for MQTT:

      Thing topic T1P1 "T1P1" {
        Channels:
          Type string : P1  [ stateTopic="tele/T1P1/RESULT" ]
          Type switch : CH1  [ stateTopic="stat/T1P1/POWER" , commandTopic="cmnd/T1P1/POWER", on="ON", off="OFF"]
          }

Then i created the items:

Switch Main "Principale" {channel="mqtt:topic:MyMQTTBroker:T1P1:CH1"}
String Var_Power "Stringa Potenza" {channel="mqtt:topic:MyMQTTBroker:T1P1:P1"}
Number Voltage "Tensione"
Number Current "Corrente"
Number Power_Actual "Potenza Attuale"
Number Power_Total "Potenza Totale"

And finally i created the rule:

var String raw_data
var String raw_kWh
var String raw_V
var String raw_A
var String raw_Hz
var String raw_W
var String raw_VAR

var Number real_kWh
var Number real_V
var Number real_A
var Number real_Hz
var Number real_W
var Number real_VAR

rule 'Analisi Potenza'
when
    Item Var_Power received update
then
    raw_data = Var_Power.state.toString.split('FE0108').get(1)
    raw_data = raw_data.split('}').get(0)

    raw_kWh = raw_data.mid(0, 8)
    raw_V = raw_data.mid(8, 8)
    raw_A = raw_data.mid(16, 8)
    //raw_Hz = raw_data.mid(24, 8)
    raw_W = raw_data.mid(32, 8)
    //raw_VAR = raw_data.mid(40, 8)

    real_kWh = Double.parseDouble(raw_kWh.mid(6, 2) + raw_kWh.mid(4, 2) + raw_kWh.mid(2, 2) + raw_kWh.mid(0, 2))/100
    real_V = Double.parseDouble(raw_V.mid(6, 2) + raw_V.mid(4, 2) + raw_V.mid(2, 2) + raw_V.mid(0, 2))/10
    real_A = Double.parseDouble(raw_A.mid(6, 2) + raw_A.mid(4, 2) + raw_A.mid(2, 2) + raw_A.mid(0, 2))/10000
    //real_Hz = Double.parseDouble(raw_Hz.mid(6, 2) + raw_Hz.mid(4, 2) + raw_Hz.mid(2, 2) + raw_Hz.mid(0, 2))/100
    real_W = Double.parseDouble(raw_W.mid(6, 2) + raw_W.mid(4, 2) + raw_W.mid(2, 2) + raw_W.mid(0, 2))/100
    //real_VAR = Double.parseDouble(raw_VAR.mid(6, 2) + raw_VAR.mid(4, 2) + raw_VAR.mid(2, 2) + raw_VAR.mid(0, 2))/100

    //logInfo('Raw', raw_data)
    //logInfo('kWh', real_kWh.toString)
    //logInfo('V', real_V.toString)
    //logInfo('A', real_A.toString)
    //logInfo('Hz', real_Hz.toString)
    //logInfo('W', real_W.toString)
    //logInfo('VAR', real_VAR.toString)

    Voltage.postUpdate(real_V)
    Current.postUpdate(real_A)
    Power_Actual.postUpdate(real_W)
    Power_Total.postUpdate(real_kWh)

end

// example raw _data
// 04000000 76200000 00000000 00500000 00000000 00000000 00000000 00100000 XX

The only remeining thing is to display it inside a sitemap:

    Frame label="Principale" {
        Text item=Voltage label="Tensione [%.1f V]" icon=pressure
        Text item=Current label="Corrente [%.1f A]" icon=pressure
        Text item=Power_Actual label="Potenza [%.1f W]" icon=pressure
        Text item=Power_Total label="Potenza Totale [%.1f kWh]" icon=pressure
    }

I made this projext by myself but i would like to share it with you in case someone else need this too and also to have some kind of documentation for the future in case i will need it :smiley:

Have a nice day and #Stayathome!

1 Like