PyBLNET 0.9.3__py3-none-any.whl → 0.9.5__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.
- {PyBLNET-0.9.3.dist-info → PyBLNET-0.9.5.dist-info}/METADATA +2 -2
- {PyBLNET-0.9.3.dist-info → PyBLNET-0.9.5.dist-info}/RECORD +9 -8
- {PyBLNET-0.9.3.dist-info → PyBLNET-0.9.5.dist-info}/WHEEL +1 -1
- pyblnet/__init__.py +1 -1
- pyblnet/blnet_conn.py +1 -1
- pyblnet/blnet_parser.py +13 -13
- pyblnet/tests/test_parser.py +28 -0
- {PyBLNET-0.9.3.dist-info → PyBLNET-0.9.5.dist-info}/LICENSE.txt +0 -0
- {PyBLNET-0.9.3.dist-info → PyBLNET-0.9.5.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyBLNET
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.5
|
|
4
4
|
Summary: Automate wireless communication to UVR1611 via BL-NET
|
|
5
5
|
Home-page: https://github.com/nielstron/pyblnet/
|
|
6
6
|
Author: nielstron
|
|
@@ -26,7 +26,7 @@ Requires-Dist: htmldom
|
|
|
26
26
|
Requires-Dist: requests
|
|
27
27
|
|
|
28
28
|
# PyBLNET - a very basic python BL-NET bridge
|
|
29
|
-
[](https://github.com/nielstron/pyblnet/actions/workflows/build.yml)
|
|
30
30
|
[](https://coveralls.io/github/nielstron/pyblnet?branch=master)
|
|
31
31
|
|
|
32
32
|
A package that connects to the BL-NET that is connected itself to a UVR1611 device by Technische Alternative.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
pyblnet/__init__.py,sha256=
|
|
1
|
+
pyblnet/__init__.py,sha256=SKhnePT98Y7lh13XX2qCiTJwPOi_JBVHTIZWo5k5iyA,499
|
|
2
2
|
pyblnet/blnet.py,sha256=t4NKLZib_kV-S8ZEnNim8ML52gE99nrWzlt_GZCjxC4,7570
|
|
3
|
-
pyblnet/blnet_conn.py,sha256=
|
|
4
|
-
pyblnet/blnet_parser.py,sha256=
|
|
3
|
+
pyblnet/blnet_conn.py,sha256=6ji91hnm7X5W6v6rHAMNYmwOjTPtyeSxAriYwQdcWks,12612
|
|
4
|
+
pyblnet/blnet_parser.py,sha256=Yy8KpQJeDf65gWS1EyRyi3sUxXMx5cRhQhslwqEAfeU,4925
|
|
5
5
|
pyblnet/blnet_web.py,sha256=1fQ8PRkv2RW6ikdTUm7s_eSFDK_pp5MQenJWhzB-n5k,11776
|
|
6
6
|
pyblnet/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
pyblnet/tests/test_parser.py,sha256=tq9AzqSS-biUjOMniZF78DucU5Q3K9kL4lzBl8pFZVg,1462
|
|
7
8
|
pyblnet/tests/test_web.py,sha256=8ypDQhkgzR2PDg0lYaRwFYDlk1x3niJY7xOTk6KZCmM,7039
|
|
8
9
|
pyblnet/tests/test_structure/580500.alternative.htm,sha256=yN1OE4EJDpTk-vAFjI-OXYYSJIWRIikiQLRsf8rF3LQ,6968
|
|
9
10
|
pyblnet/tests/test_structure/580500.htm,sha256=T1xwHQlvqZBEG72HX7trw4f-UaiO9zY9f1-mNbDAx9I,6992
|
|
@@ -16,8 +17,8 @@ pyblnet/tests/test_structure/par.htm,sha256=i-VuEEaeAuEy6JmHEZVJIyNisOFBT6s6LLF5
|
|
|
16
17
|
pyblnet/tests/test_structure/server_control.py,sha256=4lvHzqph-8steCaOJlOwdbz4X7mS6LIwXNoGyc8Uh-0,1650
|
|
17
18
|
pyblnet/tests/web_raw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
19
|
pyblnet/tests/web_raw/web_state.py,sha256=RQdSu8S6LsEg8kkqpLVnhOv_tL0Pn8c2MCb8qXT2Dxk,5234
|
|
19
|
-
PyBLNET-0.9.
|
|
20
|
-
PyBLNET-0.9.
|
|
21
|
-
PyBLNET-0.9.
|
|
22
|
-
PyBLNET-0.9.
|
|
23
|
-
PyBLNET-0.9.
|
|
20
|
+
PyBLNET-0.9.5.dist-info/LICENSE.txt,sha256=qLriK0Yi_eGmEwdftMY0hOmBLuYbPHMXDqzc7GZCAps,1077
|
|
21
|
+
PyBLNET-0.9.5.dist-info/METADATA,sha256=CbMpMDV4EBoNfWBSBXyDLNA53WzRV4evraBjDbJt-aA,3877
|
|
22
|
+
PyBLNET-0.9.5.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
23
|
+
PyBLNET-0.9.5.dist-info/top_level.txt,sha256=kgkmudEmlKVRznWy4MId7Gz3z075jYSz3Z88Vc6oGm0,8
|
|
24
|
+
PyBLNET-0.9.5.dist-info/RECORD,,
|
pyblnet/__init__.py
CHANGED
pyblnet/blnet_conn.py
CHANGED
pyblnet/blnet_parser.py
CHANGED
|
@@ -79,20 +79,18 @@ class BLNETParser:
|
|
|
79
79
|
self.digital[channel + 1] = self._convert_digital(digital, channel)
|
|
80
80
|
|
|
81
81
|
self.speed = {}
|
|
82
|
-
for
|
|
83
|
-
self.speed[
|
|
82
|
+
for idx, value in enumerate(speed):
|
|
83
|
+
self.speed[idx + 1] = self._convert_speed(value)
|
|
84
84
|
|
|
85
85
|
self.energy = {}
|
|
86
86
|
for channel in range(0, 2):
|
|
87
|
-
self.
|
|
88
|
-
|
|
89
|
-
)
|
|
87
|
+
energy = self._convert_energy(MWh[channel], kWh[channel], active, channel)
|
|
88
|
+
self.energy[channel + 1] = energy
|
|
90
89
|
|
|
91
90
|
self.power = {}
|
|
92
|
-
for
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
91
|
+
for idx, value in enumerate(power):
|
|
92
|
+
power = self._convert_power(value, active, idx)
|
|
93
|
+
self.power[idx + 1] = power
|
|
96
94
|
|
|
97
95
|
def to_dict(self):
|
|
98
96
|
"""
|
|
@@ -139,7 +137,7 @@ class BLNETParser:
|
|
|
139
137
|
if value & SPEED_ACTIVE:
|
|
140
138
|
return None
|
|
141
139
|
else:
|
|
142
|
-
return value & SPEED_MASK
|
|
140
|
+
return round(value & SPEED_MASK, 3)
|
|
143
141
|
|
|
144
142
|
def _convert_energy(self, mwh, kwh, active, position):
|
|
145
143
|
"""
|
|
@@ -148,7 +146,7 @@ class BLNETParser:
|
|
|
148
146
|
"""
|
|
149
147
|
if active & position:
|
|
150
148
|
kwh = self._calculate_value(kwh, 0.1, INT16_POSITIVE_MASK)
|
|
151
|
-
return mwh * 1000 + kwh
|
|
149
|
+
return round(mwh * 1000 + kwh, 3)
|
|
152
150
|
else:
|
|
153
151
|
return None
|
|
154
152
|
|
|
@@ -158,12 +156,14 @@ class BLNETParser:
|
|
|
158
156
|
@return its power
|
|
159
157
|
"""
|
|
160
158
|
if active & position:
|
|
161
|
-
|
|
159
|
+
value = self._calculate_value(value, 1 / 2560, INT32_MASK, INT32_SIGN)
|
|
160
|
+
value = round(value, 3)
|
|
161
|
+
return value
|
|
162
162
|
else:
|
|
163
163
|
return None
|
|
164
164
|
|
|
165
165
|
def _calculate_value(
|
|
166
|
-
self, value, multiplier=1, positive_mask=POSITIVE_VALUE_MASK, signbit=SIGN_BIT
|
|
166
|
+
self, value, multiplier=1.0, positive_mask=POSITIVE_VALUE_MASK, signbit=SIGN_BIT
|
|
167
167
|
):
|
|
168
168
|
result = value & positive_mask
|
|
169
169
|
if value & signbit:
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from pyblnet.blnet_parser import BLNETParser
|
|
2
|
+
import unittest
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestParser(unittest.TestCase):
|
|
6
|
+
|
|
7
|
+
def test_parser_ok(self):
|
|
8
|
+
data = b'} \xb5"f"\x03"~!\x8e"\x16!\xe0 \xff \xf3 \xf8 \x00\x00=!\x01\x00\x00`\xe2!\x00\x00\x80\x00\x00\x00\x00,\x00\xa4(\x06\x00DhI\x82\x1d\x04Ce\xc0\x00'
|
|
9
|
+
parser = BLNETParser(data)
|
|
10
|
+
parsed_values = parser.to_dict()
|
|
11
|
+
expected_values = {
|
|
12
|
+
'analog': {1: 12.5, 2: 69.3, 3: 61.4, 4: 51.5, 5: 38.2, 6: 65.4, 7: 27.8, 8: 22.4, 9: 25.5, 10: 24.3, 11: 24.8, 12: 0, 13: 31.7, 14: 1, 15: 0, 16: 48.2},
|
|
13
|
+
'digital': {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0},
|
|
14
|
+
'speed': {1: None, 2: 0, 3: 0, 4: 0},
|
|
15
|
+
'energy': {1: None, 2: None},
|
|
16
|
+
'power': {1: None, 2: None}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
assert parsed_values['analog'] == expected_values['analog']
|
|
20
|
+
assert parsed_values['digital'] == expected_values['digital']
|
|
21
|
+
assert parsed_values['speed'] == expected_values['speed']
|
|
22
|
+
assert parsed_values['energy'] == expected_values['energy']
|
|
23
|
+
assert parsed_values['power'] == expected_values['power']
|
|
24
|
+
|
|
25
|
+
def test_parser_not_ok(self):
|
|
26
|
+
data = b'broken} \xb5"f"\x03"~!\x8e"\x16!\xe0 \xff \xf3 \xf8 \x00\x00=!\x01\x00\x00`\xe2!\x00\x00\x80\x00\x00\x00\x00,\x00\xa4(\x06\x00DhI\x82\x1d\x04Ce\xc0\x00'
|
|
27
|
+
with self.assertRaises(ValueError):
|
|
28
|
+
parser = BLNETParser(data)
|
|
File without changes
|
|
File without changes
|