PyBLNET 0.11.0__py3-none-any.whl → 0.12.0__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/__init__.py CHANGED
@@ -10,5 +10,5 @@ try:
10
10
  except ImportError as e:
11
11
  warnings.warn(ImportWarning(e))
12
12
 
13
- VERSION = (0, 11, 0)
13
+ VERSION = (0, 12, 0)
14
14
 
pyblnet/blnet.py CHANGED
@@ -96,7 +96,8 @@ class BLNET(object):
96
96
  data["analog"] = self._convert_web(blnet_session.read_analog_values())
97
97
  data["digital"] = self._convert_web(blnet_session.read_digital_values())
98
98
  for entry in data["analog"].values():
99
- entry["type"] = WEB_UNIT_TYPES.get(entry.get("unit_of_measurement"))
99
+ # digital inputs come with their type, others by their unit
100
+ entry.setdefault("type", WEB_UNIT_TYPES.get(entry.get("unit_of_measurement")))
100
101
  if self.blnet_direct:
101
102
  direct = self.blnet_direct.get_latest(self.max_retries)[0]
102
103
  # Override values for analog and digital as values are
@@ -104,7 +105,10 @@ class BLNET(object):
104
105
  for domain in ["analog", "digital"]:
105
106
  for id, value in direct[domain].items():
106
107
  if data[domain].get(id) is not None:
107
- data[domain][id]["value"] = value
108
+ # Keep the web value if the direct one is missing: a
109
+ # UVR1611 on CAN sends digital inputs as unused inputs
110
+ if value is not None:
111
+ data[domain][id]["value"] = value
108
112
  elif not self.blnet_web:
109
113
  if value is None:
110
114
  continue
pyblnet/blnet_parser.py CHANGED
@@ -27,7 +27,8 @@ TYPE_NONE = 0x0000
27
27
  TYPE_DIGITAL = 0x1000
28
28
  TYPE_TEMP = 0x2000
29
29
  TYPE_VOLUME = 0x3000
30
- TYPE_RADIATION = 0x4000
30
+ # V110 TTTT TTTT TTTT in TA's interface spec, in W/m²
31
+ TYPE_RADIATION = 0x6000
31
32
  TYPE_RAS = 0x7000
32
33
  RAS_POSITIVE_MASK = 0x01FF
33
34
  # Temperature input without sensor (or with a broken wire): all value bits set, 409.5 °C
pyblnet/blnet_web.py CHANGED
@@ -15,6 +15,24 @@ import re
15
15
  from builtins import int
16
16
  from html.parser import HTMLParser
17
17
 
18
+ # An input on the inputs page: a measured value with unit, or the state of a
19
+ # digital input. The value of a digital input is "1" (on) or "0" (off), like
20
+ # the direct connection reports it.
21
+ INPUT_PATTERN = re.compile(
22
+ r"(?P<id>\d+):&nbsp;(?P<name>.+)\n(&nbsp;){3,6}"
23
+ r"(?:(?P<value>(-&nbsp;)?\d+,\d+) (?P<unit_of_measurement>.+?) &nbsp;&nbsp;"
24
+ r"|(?P<state>AUS|EIN|OFF|ON)(&nbsp;)+)PAR?"
25
+ )
26
+ DIGITAL_INPUT_STATES = {"AUS": "0", "OFF": "0", "EIN": "1", "ON": "1"}
27
+
28
+ # A mixer on the outputs page: its mode, then the state of the opening output
29
+ # and of the closing output, which has the next id
30
+ MIXER_OUTPUT_PATTERN = re.compile(
31
+ r"(?P<id>\d+):&nbsp;(?P<name>.+)\n(&nbsp;)+(?P<mode>AUTO|HAND) .*PAR\?.*\n"
32
+ r"(&nbsp;)+auf:(&nbsp;)+(?P<open>AUS|EIN)\n"
33
+ r"(&nbsp;)*(?P<id_close>\d+):&nbsp;zu:(&nbsp;)+(?P<close>AUS|EIN)"
34
+ )
35
+
18
36
 
19
37
  class _ElementTextParser(HTMLParser):
20
38
  """
@@ -256,24 +274,24 @@ class BLNETWeb(object):
256
274
  data = list()
257
275
 
258
276
  # search for data by regular expression
259
- match_iter = re.finditer(
260
- r"(?P<id>\d+):&nbsp;(?P<name>.+)\n(&nbsp;){3,6}(?P<value>(-&nbsp;)?\d+,\d+) (?P<unit_of_measurement>.+?) &nbsp;&nbsp;PAR?",
261
- data_raw,
262
- )
263
- # parse a dict of the match and save them all in a list
264
- for match in match_iter:
265
- match_dict = match.groupdict()
266
- # convert html entities to unicode characters
267
- for key, value in match_dict.items():
268
- # replace &nbsp; by " " since it is not unescaped as expected
269
- value = value.replace("&nbsp;", " ")
270
- if key == "value":
271
- # for values
272
- # also replace decimal "," by "." and remove "&nbsp;" completely
273
- value = value.replace(",", ".").replace(" ", "")
274
- match_dict[key] = html.unescape(value)
275
- # and append formatted dict
276
- data.append(match_dict)
277
+ for match in INPUT_PATTERN.finditer(data_raw):
278
+ # convert html entities to unicode characters,
279
+ # replace &nbsp; by " " since it is not unescaped as expected
280
+ entry = {
281
+ "id": match["id"],
282
+ "name": html.unescape(match["name"].replace("&nbsp;", " ")),
283
+ }
284
+ if match["state"] is not None:
285
+ entry["value"] = DIGITAL_INPUT_STATES[match["state"]]
286
+ entry["unit_of_measurement"] = None
287
+ entry["type"] = "digital"
288
+ else:
289
+ # replace decimal "," by "." and remove "&nbsp;" completely
290
+ entry["value"] = match["value"].replace("&nbsp;", "").replace(",", ".")
291
+ entry["unit_of_measurement"] = html.unescape(
292
+ match["unit_of_measurement"].replace("&nbsp;", " ")
293
+ )
294
+ data.append(entry)
277
295
  return data
278
296
 
279
297
  def read_digital_values(self):
@@ -316,6 +334,17 @@ class BLNETWeb(object):
316
334
  match_dict[key] = html.unescape(value)
317
335
  # and append formatted dict
318
336
  data.append(match_dict)
337
+ # a mixer uses two outputs (open, close) with a common mode
338
+ for match in MIXER_OUTPUT_PATTERN.finditer(data_raw):
339
+ name = html.unescape(match["name"].replace("&nbsp;", " "))
340
+ for id, direction, value in [
341
+ (match["id"], "auf", match["open"]),
342
+ (match["id_close"], "zu", match["close"]),
343
+ ]:
344
+ data.append(
345
+ {"id": id, "name": f"{name} {direction}", "mode": match["mode"], "value": value}
346
+ )
347
+ data.sort(key=lambda entry: int(entry["id"]))
319
348
  return data
320
349
 
321
350
  def set_digital_value(self, digital_id, value):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: PyBLNET
3
- Version: 0.11.0
3
+ Version: 0.12.0
4
4
  Summary: Automate wireless communication to UVR1611 via BL-NET
5
5
  Keywords: python,uvr1611,blnet,technische alternative,home automation,iot
6
6
  Author-email: nielstron <n.muendler@posteo.de>
@@ -24,8 +24,8 @@ Provides-Extra: test
24
24
  Import-Name: pyblnet
25
25
 
26
26
  # PyBLNET - a very basic python BL-NET bridge
27
- ![PyPI - Version](https://img.shields.io/pypi/v/pyblnet)
28
- ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyblnet)
27
+ [![PyPI - Version](https://img.shields.io/pypi/v/pyblnet)](https://pypi.org/project/PyBLNET/)
28
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyblnet)](https://pypi.org/project/PyBLNET/)
29
29
  [![Build status](https://github.com/nielstron/pyblnet/actions/workflows/build.yml/badge.svg)](https://github.com/nielstron/pyblnet/actions/workflows/build.yml)
30
30
  [![Coverage Status](https://coveralls.io/repos/github/nielstron/pyblnet/badge.svg?branch=master)](https://coveralls.io/github/nielstron/pyblnet?branch=master)
31
31
 
@@ -0,0 +1,9 @@
1
+ pyblnet/__init__.py,sha256=XtfpQ0RcQfjTKETItIrH6cZzGFlNhRK3eapXQNbfGxA,270
2
+ pyblnet/blnet.py,sha256=Nthg9z5vwR5dlZUBVrO7wd-COwLXQD6hy_8qZBpV7UA,8994
3
+ pyblnet/blnet_conn.py,sha256=kuS6EkxTNx3lT390ZZzOg4zB7TNfeMO_b_d4nKuhEiY,15706
4
+ pyblnet/blnet_parser.py,sha256=YBJrhL2t88bCWgrBw1k7EO2FfIocDdUfIGAWH4CKPj4,5915
5
+ pyblnet/blnet_web.py,sha256=OR1SFPpen2qR5UlIxFx3g0vOIL-uHbgnYu-FksdMXvE,14825
6
+ pyblnet-0.12.0.dist-info/licenses/LICENSE.txt,sha256=qLriK0Yi_eGmEwdftMY0hOmBLuYbPHMXDqzc7GZCAps,1077
7
+ pyblnet-0.12.0.dist-info/WHEEL,sha256=rLJE8OLPBZbz7tqxs1yD-wA-ADa1Ec5PuYU-Y_PNWDI,81
8
+ pyblnet-0.12.0.dist-info/METADATA,sha256=Jkrp-NRqmw1AsMfbPHl3oP50DamPFHXa729FDiewALc,4170
9
+ pyblnet-0.12.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- pyblnet/__init__.py,sha256=ULgLk5BwCamijzOX3za0uYRrvmLplsCOz3KX2Gr-lt0,270
2
- pyblnet/blnet.py,sha256=URwf9hgHBTiiYnzKZdH7Ch3W6GbDyFej_sAKZf4GD10,8702
3
- pyblnet/blnet_conn.py,sha256=kuS6EkxTNx3lT390ZZzOg4zB7TNfeMO_b_d4nKuhEiY,15706
4
- pyblnet/blnet_parser.py,sha256=ej3bFWXuuDAC8tzm73-tHOGw6LRxf61UIIbqNfpXmqc,5860
5
- pyblnet/blnet_web.py,sha256=QqqTqa6BWlKs_ZZRubpw9HwA6N4Ttv9Y3NWUrmbrXu4,13438
6
- pyblnet-0.11.0.dist-info/licenses/LICENSE.txt,sha256=qLriK0Yi_eGmEwdftMY0hOmBLuYbPHMXDqzc7GZCAps,1077
7
- pyblnet-0.11.0.dist-info/WHEEL,sha256=rLJE8OLPBZbz7tqxs1yD-wA-ADa1Ec5PuYU-Y_PNWDI,81
8
- pyblnet-0.11.0.dist-info/METADATA,sha256=pXwu7fe7yQhRNLmGX_LGkRsw7Z7sXeENF2UweT0w3n8,4096
9
- pyblnet-0.11.0.dist-info/RECORD,,