jrouvier / esphome-emporia-vue-utility

Alternative ESPHome firmware for the Emporia Vue Utility Connect
GNU General Public License v2.0
75 stars 17 forks source link

Fix negative watt values #5

Closed dailow closed 2 years ago

jrouvier commented 2 years ago

@dailow, thanks for your patience. Subtracting 0x1000000 is actually off by one, should actually subtract 0xFFFFFF. The "proper" way would actually be watts = ((~watts) & 0xFFFFFF) * -1, but watts -= 0xFFFFFF works as well and is much cleaner. I've taken the liberty of expanding the logic a bit so it will handle both of the most common ways of expressing negative numbers.