I am trying to convert a power meter reading from hex to decimal using signed 2 compliment as per here - Hexadecimal to Decimal Converter (rapidtables.com)
For example:
000001A1 = 417
FFFFFCAF = -849
Now I am using this template for the conversion:
value_template: “{{ 000001A1 | int(base=16) }}”
This works fine for the the first example as it converts to 417
However for the second i.e.
value_template: “{{ FFFFFCAF | int(base=16) }}”
It converts to 4294966447 instead of -849.
What is the templating code I need to properly return decimal from signed 2’s complement?
Tried to google out but really stuck - any help appreciated.
BTW its negative because of solar export to the grid.
Thanks