Skip to content

Commit

Permalink
Merge pull request snaptec#2828 from okaegi/sma604
Browse files Browse the repository at this point in the history
lambda pymodbus
  • Loading branch information
LKuemmel authored Apr 5, 2024
2 parents 1da98a4 + 1b14971 commit 81216c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/modules/smarthome/lambda_/watt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
import struct
import codecs
import logging
from pymodbus.payload import BinaryPayloadBuilder, Endian
from pymodbus.payload import BinaryPayloadBuilder
from pymodbus.client.sync import ModbusTcpClient
from smarthome.smartlog import initlog
from smarthome.smartret import writeret
# fix for pymodbus endian class (changes once 2023 august to enum to uppercases only,
# checked during runtime,
# not compatible betwwen openwb 1.9 (want lowercases) and openwb 2.0 (wants upercase))
auto = "@"
big = ">"
little = "<"
named_tuple = time.localtime() # getstruct_time
time_string = time.strftime("%m/%d/%Y, %H:%M:%S lambda watty.py", named_tuple)
devicenumber = int(sys.argv[1])
Expand Down Expand Up @@ -100,7 +106,7 @@
# modbus write
if modbuswrite == 1:
# andernfalls absturz bei negativen Zahlen
builder = BinaryPayloadBuilder(byteorder=Endian.BIG)
builder = BinaryPayloadBuilder(byteorder=big)
builder.reset()
builder.add_16bit_int(neupower)
pay = builder.to_registers()
Expand Down

0 comments on commit 81216c6

Please sign in to comment.