Skip to content

Commit

Permalink
fix negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick762 committed Jan 7, 2024
1 parent b752535 commit db4e25e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.pyc
example.yaml
spec.pdf
*.svg
4 changes: 3 additions & 1 deletion custom_components/solvis_modbus/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import async_timeout
from pymodbus.client import ModbusTcpClient
from pymodbus.payload import BinaryPayloadDecoder, Endian

from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import (
Expand Down Expand Up @@ -76,7 +77,8 @@ async def _async_update_data(self):

# Add data to return values
if(len(result.registers) == 1):
parsed_data[register.name] = round(result.registers[0] * register.multiplier, 2)
d = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.BIG)
parsed_data[register.name] = round(d.decode_16bit_int() * register.multiplier, 2)

except TimeoutError:
self.logger.warning("Polling timed out")
Expand Down

0 comments on commit db4e25e

Please sign in to comment.