Open amravs opened 1 year ago
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.
I think it’s the meaning of when +ve and -ve
Regards Sunny Varma
From: Nazar Mokrynskyi @.> Sent: Wednesday, August 23, 2023 9:57:55 AM To: nazar-pc/solax-local-api-docs @.> Cc: amravs @.>; Author @.> Subject: Re: [nazar-pc/solax-local-api-docs] Function needs to return a negative number (Issue #4)
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.
— Reply to this email directly, view it on GitHubhttps://github.com/nazar-pc/solax-local-api-docs/issues/4#issuecomment-1689561533, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARDTAV5H7SAKT6WHTY5U74TXWXAZHANCNFSM6AAAAAA33DP3F4. You are receiving this because you authored the thread.Message ID: @.***>
at a guess they are simple 2's complement numbers poorly converted
Yes you’re correct, I’m aligning the battery power inputs to the power card plus in home assistant where -ve for production and +ve for consumption.
Regards Sunny Varma
From: Simone @.> Sent: Wednesday, August 23, 2023 12:27:09 PM To: nazar-pc/solax-local-api-docs @.> Cc: amravs @.>; Author @.> Subject: Re: [nazar-pc/solax-local-api-docs] Function needs to return a negative number (Issue #4)
at a glance they are simple 2's complement numbers poorly converted
— Reply to this email directly, view it on GitHubhttps://github.com/nazar-pc/solax-local-api-docs/issues/4#issuecomment-1689790657, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARDTAV43FVAFXZGZJSZQLHTXWXSI3ANCNFSM6AAAAAA33DP3F4. You are receiving this because you authored the thread.Message ID: @.***>
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?