nazar-pc / solax-local-api-docs

Solax local API docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Function needs to return a negative number

amravs opened this issue · comments

commented

Hi

This is great work and helping me immensely extract data but when I apply the functions the flow of energy is always positive eg battery power should flow in and out depending on the demand?

function read16BitSigned(n) {
if (n < 32768) {
return n;
} else {
return n - 65536;
}

The returned value is always positive and a slight tweak to ensure a signed return would be to multiply the < 32768 by -1?

I aplied this change to my config and my energy flows are now correct.

function read16BitSigned(n) {
if (n < 32768) {
return n*-1;
} else {
return n - 65536;
}

What do you think?

If n is 32768 or more the result will be negative. I have no idea why manufacturer couldn't just return normal signed integers, but we have what we have.

commented
commented

at a guess they are simple 2's complement numbers poorly converted

commented