PyBLNET 0.9.2__tar.gz → 0.9.4__tar.gz

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.
Files changed (29) hide show
  1. {PyBLNET-0.9.2 → pyblnet-0.9.4}/PKG-INFO +1 -1
  2. {PyBLNET-0.9.2 → pyblnet-0.9.4}/PyBLNET.egg-info/PKG-INFO +1 -1
  3. {PyBLNET-0.9.2 → pyblnet-0.9.4}/PyBLNET.egg-info/SOURCES.txt +1 -0
  4. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/__init__.py +1 -1
  5. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/blnet_conn.py +1 -1
  6. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/blnet_parser.py +17 -7
  7. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/blnet_web.py +2 -0
  8. pyblnet-0.9.4/pyblnet/tests/test_parser.py +24 -0
  9. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_web.py +10 -10
  10. {PyBLNET-0.9.2 → pyblnet-0.9.4}/LICENSE.txt +0 -0
  11. {PyBLNET-0.9.2 → pyblnet-0.9.4}/PyBLNET.egg-info/dependency_links.txt +0 -0
  12. {PyBLNET-0.9.2 → pyblnet-0.9.4}/PyBLNET.egg-info/requires.txt +0 -0
  13. {PyBLNET-0.9.2 → pyblnet-0.9.4}/PyBLNET.egg-info/top_level.txt +0 -0
  14. {PyBLNET-0.9.2 → pyblnet-0.9.4}/README.md +0 -0
  15. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/blnet.py +0 -0
  16. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/__init__.py +0 -0
  17. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_structure/580500.alternative.htm +0 -0
  18. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_structure/580500.htm +0 -0
  19. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_structure/580600.htm +0 -0
  20. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_structure/__init__.py +0 -0
  21. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_structure/blnet_mock_server.py +0 -0
  22. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_structure/main.htm +0 -0
  23. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_structure/main.html +0 -0
  24. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_structure/par.htm +0 -0
  25. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/test_structure/server_control.py +0 -0
  26. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/web_raw/__init__.py +0 -0
  27. {PyBLNET-0.9.2 → pyblnet-0.9.4}/pyblnet/tests/web_raw/web_state.py +0 -0
  28. {PyBLNET-0.9.2 → pyblnet-0.9.4}/setup.cfg +0 -0
  29. {PyBLNET-0.9.2 → pyblnet-0.9.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyBLNET
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: Automate wireless communication to UVR1611 via BL-NET
5
5
  Home-page: https://github.com/nielstron/pyblnet/
6
6
  Author: nielstron
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyBLNET
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: Automate wireless communication to UVR1611 via BL-NET
5
5
  Home-page: https://github.com/nielstron/pyblnet/
6
6
  Author: nielstron
@@ -12,6 +12,7 @@ pyblnet/blnet_conn.py
12
12
  pyblnet/blnet_parser.py
13
13
  pyblnet/blnet_web.py
14
14
  pyblnet/tests/__init__.py
15
+ pyblnet/tests/test_parser.py
15
16
  pyblnet/tests/test_web.py
16
17
  pyblnet/tests/test_structure/580500.alternative.htm
17
18
  pyblnet/tests/test_structure/580500.htm
@@ -10,7 +10,7 @@ try:
10
10
  except ImportError as e:
11
11
  warnings.warn(ImportWarning(e))
12
12
 
13
- VERSION = (0, 9, 2)
13
+ VERSION = (0, 9, 4)
14
14
 
15
15
  __version__ = ".".join([str(i) for i in VERSION])
16
16
  __author__ = "nielstron"
@@ -3,7 +3,7 @@
3
3
  """
4
4
  Created on 09.08.2018
5
5
 
6
- This is basically a python port of of a script by berwinter
6
+ This is basically a python port of a script by berwinter
7
7
  https://github.com/berwinter/uvr1611/blob/master/lib/backend/blnet-connection.inc.php
8
8
 
9
9
  @author: Niels
@@ -80,19 +80,29 @@ class BLNETParser:
80
80
 
81
81
  self.speed = {}
82
82
  for channel in range(0, 4):
83
- self.speed[channel + 1] = round(self._convert_speed(speed[channel]), 3)
83
+ speed = self._convert_speed(speed[channel])
84
+ if speed:
85
+ self.speed[channel + 1] = round(speed, 3)
86
+ else:
87
+ break
84
88
 
85
89
  self.energy = {}
86
90
  for channel in range(0, 2):
87
- self.energy[channel + 1] = round(
88
- self._convert_energy(MWh[channel], kWh[channel], active, channel), 3
89
- )
91
+ energy = self._convert_energy(MWh[channel], kWh[channel], active, channel)
92
+ if energy:
93
+ self.energy[channel + 1] = round(energy, 3)
94
+ else:
95
+ break
90
96
 
91
97
  self.power = {}
92
98
  for channel in range(0, 2):
93
- self.power[channel + 1] = round(
94
- self._convert_power(power[channel], active, channel), 3
95
- )
99
+ power = self._convert_power(power[channel], active, channel)
100
+ if power:
101
+ self.power[channel + 1] = round(
102
+ self._convert_power(power[channel], active, channel), 3
103
+ )
104
+ else:
105
+ break
96
106
 
97
107
  def to_dict(self):
98
108
  """
@@ -241,6 +241,8 @@ class BLNETWeb(object):
241
241
  return None
242
242
  # get the element containing the interesting information
243
243
  dom = dom.find("div.c")[1]
244
+ if dom is None:
245
+ return None
244
246
 
245
247
  # filter out the text
246
248
  data_raw = dom.text()
@@ -0,0 +1,24 @@
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': {},
15
+ 'energy': {},
16
+ 'power': {}
17
+ }
18
+
19
+ assert parsed_values == expected_values
20
+
21
+ def test_parser_not_ok(self):
22
+ 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'
23
+ with self.assertRaises(ValueError):
24
+ parser = BLNETParser(data)
@@ -21,7 +21,7 @@ class OfflineTest(unittest.TestCase):
21
21
  url = ADDRESS
22
22
 
23
23
  def test_blnet(self):
24
- """ Test finding the blnet """
24
+ """Test finding the blnet"""
25
25
  self.assertFalse(test_blnet(self.url, timeout=10))
26
26
 
27
27
  def test_blnet_web(self):
@@ -65,7 +65,7 @@ class BLNETWebTest(unittest.TestCase):
65
65
  self.server_control.start_server()
66
66
 
67
67
  def test_blnet(self):
68
- """ Test finding the blnet """
68
+ """Test finding the blnet"""
69
69
  self.assertTrue(test_blnet(self.url, timeout=10))
70
70
  self.server.set_blocked()
71
71
  self.assertTrue(test_blnet(self.url, timeout=10))
@@ -85,7 +85,7 @@ class BLNETWebTest(unittest.TestCase):
85
85
  self.assertTrue(blnet.logged_in())
86
86
 
87
87
  def test_blnet_fetch(self):
88
- """ Test fetching data in higher level class """
88
+ """Test fetching data in higher level class"""
89
89
  self.assertEqual(
90
90
  BLNET(
91
91
  ADDRESS, password=PASSWORD, timeout=10, use_ta=False, web_port=self.port
@@ -94,7 +94,7 @@ class BLNETWebTest(unittest.TestCase):
94
94
  )
95
95
 
96
96
  def test_blnet_fetch_fine_grained(self):
97
- """ Test fetching data in higher level class """
97
+ """Test fetching data in higher level class"""
98
98
  fetched = STATE
99
99
 
100
100
  def scratch_tuple(type, id, ret):
@@ -125,7 +125,7 @@ class BLNETWebTest(unittest.TestCase):
125
125
  )
126
126
 
127
127
  def test_blnet_turn(self):
128
- """ Test higher level turn methods """
128
+ """Test higher level turn methods"""
129
129
  blnet = BLNET(
130
130
  ADDRESS, password=PASSWORD, timeout=10, use_ta=False, web_port=self.port
131
131
  )
@@ -139,7 +139,7 @@ class BLNETWebTest(unittest.TestCase):
139
139
  self.assertEqual(self.server.get_node("1"), "1")
140
140
 
141
141
  def test_blnet_fetch_error(self):
142
- """ Test fetching data in higher level class with missing password (or otherwise denied access to the data) """
142
+ """Test fetching data in higher level class with missing password (or otherwise denied access to the data)"""
143
143
  self.assertEqual(
144
144
  BLNET(
145
145
  ADDRESS, password=None, timeout=10, use_ta=False, web_port=self.port
@@ -148,17 +148,17 @@ class BLNETWebTest(unittest.TestCase):
148
148
  )
149
149
 
150
150
  def test_blnet_web_analog(self):
151
- """ Test reading analog values """
151
+ """Test reading analog values"""
152
152
  with BLNETWeb(self.url, password=PASSWORD, timeout=10) as blnet:
153
153
  self.assertEqual(blnet.read_analog_values(), STATE_ANALOG)
154
154
 
155
155
  def test_blnet_web_digital(self):
156
- """ Test reading digital values"""
156
+ """Test reading digital values"""
157
157
  with BLNETWeb(self.url, password=PASSWORD, timeout=10) as blnet:
158
158
  self.assertEqual(blnet.read_digital_values(), STATE_DIGITAL)
159
159
 
160
160
  def test_blnet_web_set_digital(self):
161
- """ Test setting digital values """
161
+ """Test setting digital values"""
162
162
  with BLNETWeb(self.url, password=PASSWORD, timeout=10) as blnet:
163
163
  blnet.set_digital_value(10, "2")
164
164
  self.assertEqual(self.server.get_node("A"), "2")
@@ -188,7 +188,7 @@ class BLNETWebTest(unittest.TestCase):
188
188
  pass
189
189
 
190
190
  def test_blnet_web_log_out(self):
191
- """ Test setting digital values """
191
+ """Test setting digital values"""
192
192
  blnet = BLNETWeb(self.url, password=PASSWORD, timeout=10)
193
193
  self.assertFalse(blnet.logged_in())
194
194
  with blnet as blnet:
File without changes
File without changes
File without changes
File without changes
File without changes