python-qube-heatpump 1.2.1__py3-none-any.whl → 1.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_qube_heatpump/client.py +39 -8
- python_qube_heatpump/const.py +2 -0
- {python_qube_heatpump-1.2.1.dist-info → python_qube_heatpump-1.2.2.dist-info}/METADATA +1 -1
- python_qube_heatpump-1.2.2.dist-info/RECORD +8 -0
- python_qube_heatpump-1.2.1.dist-info/RECORD +0 -8
- {python_qube_heatpump-1.2.1.dist-info → python_qube_heatpump-1.2.2.dist-info}/WHEEL +0 -0
- {python_qube_heatpump-1.2.1.dist-info → python_qube_heatpump-1.2.2.dist-info}/licenses/LICENSE +0 -0
python_qube_heatpump/client.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"""Client for Qube Heat Pump."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
+
import struct
|
|
4
5
|
from typing import Optional
|
|
5
6
|
|
|
6
7
|
from pymodbus.client import AsyncModbusTcpClient
|
|
7
|
-
from pymodbus.payload import BinaryPayloadDecoder
|
|
8
|
-
from pymodbus.constants import Endian
|
|
9
8
|
|
|
10
9
|
from . import const
|
|
11
10
|
from .models import QubeState
|
|
@@ -80,16 +79,48 @@ class QubeClient:
|
|
|
80
79
|
_LOGGER.warning("Error reading address %s", address)
|
|
81
80
|
return None
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
regs = result.registers
|
|
83
|
+
val = 0
|
|
84
|
+
|
|
85
|
+
# Manual decoding to avoid pymodbus.payload dependencies
|
|
86
|
+
# Assuming Little Endian Word Order for 32-bit values [LSW, MSW] per standard Modbus often used
|
|
87
|
+
# But the original code used Endian.Little WordOrder.
|
|
88
|
+
# Decoder: byteorder=Endian.Big, wordorder=Endian.Little
|
|
89
|
+
# Big Endian Bytes: [H, L]
|
|
90
|
+
# Little Endian Words: [Reg0, Reg1] -> [LSW, MSW]
|
|
91
|
+
#
|
|
92
|
+
# Example Float32: 123.456
|
|
93
|
+
# Reg0 (LSW)
|
|
94
|
+
# Reg1 (MSW)
|
|
95
|
+
# Full 32-bit int: (Reg1 << 16) | Reg0
|
|
96
|
+
# Then pack as >I (Big Endian 32-bit int) and unpack as >f (Big Endian float)?
|
|
97
|
+
#
|
|
98
|
+
# Wait, PyModbus BinaryPayloadDecoder.fromRegisters(registers, byteorder=Endian.Big, wordorder=Endian.Little)
|
|
99
|
+
# ByteOrder Big: Normal network byte order per register.
|
|
100
|
+
# WordOrder Little: The first register is the least significant word.
|
|
101
|
+
#
|
|
102
|
+
# So:
|
|
103
|
+
# 32-bit value = (regs[1] << 16) | regs[0]
|
|
104
|
+
# Then interpret that 32-bit integer as a float.
|
|
105
|
+
# To interpret int bits as float in Python: struct.unpack('!f', struct.pack('!I', int_val))[0]
|
|
86
106
|
|
|
87
107
|
if data_type == const.DataType.FLOAT32:
|
|
88
|
-
|
|
108
|
+
# Combine 2 registers, Little Endian Word Order
|
|
109
|
+
int_val = (regs[1] << 16) | regs[0]
|
|
110
|
+
val = struct.unpack(">f", struct.pack(">I", int_val))[0]
|
|
89
111
|
elif data_type == const.DataType.INT16:
|
|
90
|
-
val =
|
|
112
|
+
val = regs[0]
|
|
113
|
+
# Signed 16-bit
|
|
114
|
+
if val > 32767:
|
|
115
|
+
val -= 65536
|
|
91
116
|
elif data_type == const.DataType.UINT16:
|
|
92
|
-
val =
|
|
117
|
+
val = regs[0]
|
|
118
|
+
elif data_type == const.DataType.UINT32:
|
|
119
|
+
val = (regs[1] << 16) | regs[0]
|
|
120
|
+
elif data_type == const.DataType.INT32:
|
|
121
|
+
val = (regs[1] << 16) | regs[0]
|
|
122
|
+
if val > 2147483647:
|
|
123
|
+
val -= 4294967296
|
|
93
124
|
else:
|
|
94
125
|
val = 0
|
|
95
126
|
|
python_qube_heatpump/const.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-qube-heatpump
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Async Modbus client for Qube Heat Pumps
|
|
5
5
|
Project-URL: Homepage, https://github.com/MattieGit/python-qube-heatpump
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/MattieGit/python-qube-heatpump/issues
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
python_qube_heatpump/__init__.py,sha256=eW8_tyAweg7YTOI599pi8gf3mt7aXW0SCw5ZyrBVJpU,57
|
|
2
|
+
python_qube_heatpump/client.py,sha256=sndRUFheuv54A7ghH9HgJKg77PTTD7UxRcSzleKUr9c,4863
|
|
3
|
+
python_qube_heatpump/const.py,sha256=sXvXRcDb1uvBgzH2lV67Me_XtUErKA3fXMLO9gEGrlQ,3680
|
|
4
|
+
python_qube_heatpump/models.py,sha256=3I5U9_rEe1r73hwY4sNAMXfIxyPjBOtx06c_mAURLDk,1141
|
|
5
|
+
python_qube_heatpump-1.2.2.dist-info/METADATA,sha256=YPOSKN5eTRec_yDqkQaUSli5h42JnbqFVYO-D5Wi0Hw,950
|
|
6
|
+
python_qube_heatpump-1.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
7
|
+
python_qube_heatpump-1.2.2.dist-info/licenses/LICENSE,sha256=qpuQXN7QwpILG9GYcmqrd3Ax5CxBZUBoT295xTgKnOM,1062
|
|
8
|
+
python_qube_heatpump-1.2.2.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
python_qube_heatpump/__init__.py,sha256=eW8_tyAweg7YTOI599pi8gf3mt7aXW0SCw5ZyrBVJpU,57
|
|
2
|
-
python_qube_heatpump/client.py,sha256=XNVCydP6uKIlUbH28FjcA9oXYumNRy5NBCqPrVMCX60,3360
|
|
3
|
-
python_qube_heatpump/const.py,sha256=bAFNIN8uwXIdQ5VGgSYdFrQYUNDcDXlxr0OkBxlKUYw,3638
|
|
4
|
-
python_qube_heatpump/models.py,sha256=3I5U9_rEe1r73hwY4sNAMXfIxyPjBOtx06c_mAURLDk,1141
|
|
5
|
-
python_qube_heatpump-1.2.1.dist-info/METADATA,sha256=nqZty88ZKHR7RvM4F1TsxsuFpQoBetXHva29iOv8n1Q,950
|
|
6
|
-
python_qube_heatpump-1.2.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
7
|
-
python_qube_heatpump-1.2.1.dist-info/licenses/LICENSE,sha256=qpuQXN7QwpILG9GYcmqrd3Ax5CxBZUBoT295xTgKnOM,1062
|
|
8
|
-
python_qube_heatpump-1.2.1.dist-info/RECORD,,
|
|
File without changes
|
{python_qube_heatpump-1.2.1.dist-info → python_qube_heatpump-1.2.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|