Juntek Shunt > D1 Mini (tasmota) > Home assistant Monitor

I used the info provided by this thread to link my Juntek 100A shunt to Home assistant.
I appreciate this, it feels good to have this info visible without having to reach for my phone or walk to the display.

I flashed tasmota onto a D1 mini and connected the rx/tx and ground from the D1 to the juntek comm port. which is called a RJ-10, which is smaller than a phone cord end but looks similar.

-from the juntek manual-
485 communication connection interface
The interface used to connect to the computer, and it can also be
connected to another measuring module to realize multi-computer
communication. The internal sequence from left to right is: B, A, GND, NC

Connect A pin to RX Wemos pin
Connect B pin to TX Wemos pin
Connect GND pin to GND Wemos pin

Type into Tasmota console on the D1:
Setoption19 1
Baudrate 115200
SerialSend 1 <I notieced data streaming with just the R=50 register before I sent this code, when I put SerialSend1 into the console data from 50 & 51 started streaming, but it worked without issue so I didn’t worry.

I’ll paste my code so others can use it.
My code has all the sections of r50 because I wanted to monitor the values to see what info it carried
This code goes in the configuration.yaml (putting this down as it stumped me when I found the thread as a newb)

One thing I’m stumped on as this is my first HA project, is the return value for AMPS is sent as a positive number even when the amps are being drawn.

I found the value that corresponds to the negative and positive.
It’s down the string at section [12], it returns a 0 if the amps are negative and it returns a 1 if the amps are positive.

so the Current meter always tips to the right even when drawing amps.
If I figure out how to reference the section at [12] and change the value of [4] I’ll update this post.

Can anyone suggest a code that will watch the section at [12] and if it is 1 do nothing but if it is 0 it would take the value and subtract the value x 2.

var pos/neg
var amps
if [12] = 1
do nothing
if [12] = 0
pos/neg = amps - (amps + amps)

or a conversion trick to reverse polarity of an sensor value. so + 6.6amps would flip to - 6.6a

Props to the OP of the original thread, I’m mostly condensing the info from that tread and fixing his mistake with the serialsend and using english in my code.
I was able to contribute by figuring out the math and data stream to get the SOC - battery remain data into the display, and hopefully the correct amp draw info in time.

template:
  - trigger:
      - platform: mqtt
        topic: tele/D1_mini_1/RESULT

    sensor:
      - name: SOCX
        unit_of_measurement: "%"
        state: "{{ (trigger.payload.split(',')[2] | float/11000*100) }}"
      - name: Voltage
        unit_of_measurement: "V"
        state: "{{ (trigger.payload.split(',')[3] | float/100) }}"
      - name: Current
        unit_of_measurement: "A"
        state: "{{ (trigger.payload.split(',')[4] | float/100) }}"
      - name: Amp Hours Remaining
        unit_of_measurement: "AH"
        state: "{{ (trigger.payload.split(',')[5] | float/1000) }}"
      - name: Battery Remaining
        unique_id: 0000420000-1
        unit_of_measurement: "%"
        state: "{{ (trigger.payload.split(',')[5] | float/10/400) }}"
      - name: Total Power Used
        unit_of_measurement: "AH"
        state: "{{ (trigger.payload.split(',')[6] | float/1000) }}"
      - name: Elec. Consumption
        unit_of_measurement: "kW-h"
        state: "{{ (trigger.payload.split(',')[7] | float/100000) }}"
      - name: Total kW-h
        unit_of_measurement: "kW-h"
        state: "{{ (trigger.payload.split(',')[8] | float/10000) }}"
      - name: Temperature
        unit_of_measurement: "°C"
        state: "{{ (trigger.payload.split(',')[9] | float-100) }}"
      - name: VoltageXX
        unit_of_measurement: "V"
        state: "{{ (trigger.payload.split(',')[10] | float/100) }}"
      - name: CurrentXX
        unit_of_measurement: "A"
        state: "{{ (trigger.payload.split(',')[11] | float/100) }}"
      - name: pos/neg
        state: "{{ (trigger.payload.split(',')[12]) }}"
      - name: Battery Life AH
        unit_of_measurement: "AH"
        state: "{{ (trigger.payload.split(',')[13] | float/10) }}"
      - name: Internal Resistance
        unit_of_measurement: "m-Ohm"
        state: "{{ (trigger.payload.split(',')[14] | float/100) }}"
Reply

LOL someone should get a person with colloquial English language to check before they call their company Junc Tech.

Hello, can you help me please? I added Setoption19 1
Baud rate 115200
SerialSend 1 in the Tasmota console, but it doesn’t display any values. of register R=50