I ve got an Varta Battery Pulse Neo - need to get the active power over modbus tcp
Got this config:
# Modbus Varta Speicher
modbus:
- name: mb_varta ### or whatever name
type: tcp
host: 192.168.123.63 ### ip/hostname your inverter has
port: 502
sensors:
### Active Power - positive:charge / negative: discharge
- name: mb_varta_active_power
slave: 1
address: 1066
count: 1
data_type: uint
scan_interval: 5
### Active Power SF
- name: mb_varta_active_power_sf
slave: 1
address: 2066
count: 1
scan_interval: 5
and this template sensor:
sensor:
- platform: template
scan_interval: 5
sensors:
### AC power result:
mb_varta_active_power_ts:
unit_of_measurement: 'W'
device_class: power
value_template: >-
{{ ((states('sensor.mb_varta_active_power') | int) * (10 ** ((states('sensor.mb_varta_active_power_sf')| int )) )) | int }}
The Varta Register:
1066 active power R SINT16 1 W measured at internal inverter
positive: charge
negative: discharge
What is a SINT16 ? cant find SINT in Modbus Integration - only float int uint … ???
At this config i get returns like “65013” what is in reality -524 W
Varta say at Register 2066 is the Scal Factor : active power = (value in #1066) * 10 ^
(value in #2066)
But it returns only “0” and the return of the template sensor calculation is also “65013”
How can i get the right return ?
I already get the W over an TCL Script that does the job without getting the ScaleFactor:
proc ::modbus::cmd03_unpack {reqCmd rspCmd} {
# response
#station : 1 byte
#function : 1 byte (always 0x03)
#byte count : 1 byte
#data : N*2 bytes (reg1_low...reg1_hi...reg2_low...reg2_hi...)
if {[string range $reqCmd 0 1] != [string range $rspCmd 0 1]} {return [list]}
if {[binary scan [string range $reqCmd 4 5] S reqBytes] == 0} {return [list]}
set data [string range $rspCmd 3 end]
set len [string length $data]
set ret [list]
for {set i 0} {$i < $len} {incr i} {
binary scan [string range $data $i [incr i]] S byte
lappend ret $byte
}
return $ret
}
But i dont understand the TCL ?
Can anyone help please ? THX