PyBLNET 0.9.4__tar.gz → 0.10.0__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 (40) hide show
  1. pyblnet-0.10.0/.github/workflows/build.yml +50 -0
  2. pyblnet-0.10.0/.github/workflows/release.yml +22 -0
  3. pyblnet-0.10.0/.gitignore +206 -0
  4. {pyblnet-0.9.4 → pyblnet-0.10.0}/PKG-INFO +80 -83
  5. pyblnet-0.10.0/Pipfile +13 -0
  6. {pyblnet-0.9.4 → pyblnet-0.10.0}/README.md +3 -5
  7. pyblnet-0.10.0/pyblnet/__init__.py +14 -0
  8. {pyblnet-0.9.4 → pyblnet-0.10.0}/pyblnet/blnet_conn.py +8 -5
  9. {pyblnet-0.9.4 → pyblnet-0.10.0}/pyblnet/blnet_parser.py +13 -23
  10. {pyblnet-0.9.4 → pyblnet-0.10.0}/pyblnet/blnet_web.py +2 -2
  11. pyblnet-0.10.0/pyproject.toml +44 -0
  12. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_parser.py +8 -4
  13. pyblnet-0.10.0/tests/test_structure/.error.html +10 -0
  14. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_web.py +7 -7
  15. pyblnet-0.10.0/tests/web_raw/analog_values +0 -0
  16. pyblnet-0.10.0/tests/web_raw/digital_values +0 -0
  17. pyblnet-0.10.0/tests/web_raw/logged_in +0 -0
  18. pyblnet-0.10.0/tests/web_raw/main_alt_one +0 -0
  19. pyblnet-0.9.4/PyBLNET.egg-info/PKG-INFO +0 -97
  20. pyblnet-0.9.4/PyBLNET.egg-info/SOURCES.txt +0 -27
  21. pyblnet-0.9.4/PyBLNET.egg-info/dependency_links.txt +0 -1
  22. pyblnet-0.9.4/PyBLNET.egg-info/requires.txt +0 -2
  23. pyblnet-0.9.4/PyBLNET.egg-info/top_level.txt +0 -1
  24. pyblnet-0.9.4/pyblnet/__init__.py +0 -20
  25. pyblnet-0.9.4/setup.cfg +0 -4
  26. pyblnet-0.9.4/setup.py +0 -53
  27. {pyblnet-0.9.4 → pyblnet-0.10.0}/LICENSE.txt +0 -0
  28. {pyblnet-0.9.4 → pyblnet-0.10.0}/pyblnet/blnet.py +0 -0
  29. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/__init__.py +0 -0
  30. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_structure/580500.alternative.htm +0 -0
  31. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_structure/580500.htm +0 -0
  32. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_structure/580600.htm +0 -0
  33. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_structure/__init__.py +0 -0
  34. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_structure/blnet_mock_server.py +0 -0
  35. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_structure/main.htm +0 -0
  36. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_structure/main.html +0 -0
  37. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_structure/par.htm +0 -0
  38. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/test_structure/server_control.py +0 -0
  39. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/web_raw/__init__.py +0 -0
  40. {pyblnet-0.9.4/pyblnet → pyblnet-0.10.0}/tests/web_raw/web_state.py +0 -0
@@ -0,0 +1,50 @@
1
+ name: Build & Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ "**" ]
6
+ pull_request:
7
+ branches: [ "**" ]
8
+
9
+ jobs:
10
+
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v4
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+ - name: Install dependencies
24
+ run: |
25
+ pip install coverage coveralls pytest
26
+ pip install -e .
27
+ - name: Run tests
28
+ run: coverage run --source=pyblnet -m pytest tests
29
+ - name: Coverage report
30
+ run: |
31
+ coverage report
32
+ coveralls
33
+ env:
34
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35
+ COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
36
+ COVERALLS_PARALLEL: true
37
+
38
+
39
+ coveralls:
40
+ name: Indicate completion to coveralls.io
41
+ needs: build
42
+ runs-on: ubuntu-latest
43
+ container: python:3-slim
44
+ steps:
45
+ - name: Install coveralls
46
+ run: pip3 install --upgrade coveralls
47
+ - name: Finished
48
+ run: coveralls --finish
49
+ env:
50
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,22 @@
1
+ name: Python package
2
+ on:
3
+ push:
4
+ tags:
5
+ - "*.*.*"
6
+ jobs:
7
+ build:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+ # If there isn't a release for this version, create a new one.
12
+ - uses: ncipollo/release-action@v1
13
+ with:
14
+ generateReleaseNotes: true
15
+ makeLatest: true
16
+ prerelease: false
17
+ skipIfReleaseExists: true
18
+
19
+ - name: To PyPI using Flit
20
+ uses: AsifArmanRahman/to-pypi-using-flit@v1
21
+ with:
22
+ password: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,206 @@
1
+ Pipfile.lock
2
+
3
+ # Created by https://www.gitignore.io/api/python,pycharm
4
+ # Edit at https://www.gitignore.io/?templates=python,pycharm
5
+
6
+ ### PyCharm ###
7
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
8
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
9
+ .idea
10
+
11
+ # User-specific stuff
12
+ .idea/**/workspace.xml
13
+ .idea/**/tasks.xml
14
+ .idea/**/usage.statistics.xml
15
+ .idea/**/dictionaries
16
+ .idea/**/shelf
17
+
18
+ # Generated files
19
+ .idea/**/contentModel.xml
20
+
21
+ # Sensitive or high-churn files
22
+ .idea/**/dataSources/
23
+ .idea/**/dataSources.ids
24
+ .idea/**/dataSources.local.xml
25
+ .idea/**/sqlDataSources.xml
26
+ .idea/**/dynamic.xml
27
+ .idea/**/uiDesigner.xml
28
+ .idea/**/dbnavigator.xml
29
+
30
+ # Gradle
31
+ .idea/**/gradle.xml
32
+ .idea/**/libraries
33
+
34
+ # Gradle and Maven with auto-import
35
+ # When using Gradle or Maven with auto-import, you should exclude module files,
36
+ # since they will be recreated, and may cause churn. Uncomment if using
37
+ # auto-import.
38
+ # .idea/modules.xml
39
+ # .idea/*.iml
40
+ # .idea/modules
41
+
42
+ # CMake
43
+ cmake-build-*/
44
+
45
+ # Mongo Explorer plugin
46
+ .idea/**/mongoSettings.xml
47
+
48
+ # File-based project format
49
+ *.iws
50
+
51
+ # IntelliJ
52
+ out/
53
+
54
+ # mpeltonen/sbt-idea plugin
55
+ .idea_modules/
56
+
57
+ # JIRA plugin
58
+ atlassian-ide-plugin.xml
59
+
60
+ # Cursive Clojure plugin
61
+ .idea/replstate.xml
62
+
63
+ # Crashlytics plugin (for Android Studio and IntelliJ)
64
+ com_crashlytics_export_strings.xml
65
+ crashlytics.properties
66
+ crashlytics-build.properties
67
+ fabric.properties
68
+
69
+ # Editor-based Rest Client
70
+ .idea/httpRequests
71
+
72
+ # Android studio 3.1+ serialized cache file
73
+ .idea/caches/build_file_checksums.ser
74
+
75
+ ### PyCharm Patch ###
76
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
77
+
78
+ # *.iml
79
+ # modules.xml
80
+ # .idea/misc.xml
81
+ # *.ipr
82
+
83
+ # Sonarlint plugin
84
+ .idea/sonarlint
85
+
86
+ ### Python ###
87
+ # Byte-compiled / optimized / DLL files
88
+ __pycache__/
89
+ *.py[cod]
90
+ *$py.class
91
+
92
+ # C extensions
93
+ *.so
94
+
95
+ # Distribution / packaging
96
+ .Python
97
+ build/
98
+ develop-eggs/
99
+ dist/
100
+ downloads/
101
+ eggs/
102
+ .eggs/
103
+ lib/
104
+ lib64/
105
+ parts/
106
+ sdist/
107
+ var/
108
+ wheels/
109
+ share/python-wheels/
110
+ *.egg-info/
111
+ .installed.cfg
112
+ *.egg
113
+ MANIFEST
114
+
115
+ # PyInstaller
116
+ # Usually these files are written by a python script from a template
117
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
118
+ *.manifest
119
+ *.spec
120
+
121
+ # Installer logs
122
+ pip-log.txt
123
+ pip-delete-this-directory.txt
124
+
125
+ # Unit test / coverage reports
126
+ htmlcov/
127
+ .tox/
128
+ .nox/
129
+ .coverage
130
+ .coverage.*
131
+ .cache
132
+ nosetests.xml
133
+ coverage.xml
134
+ *.cover
135
+ .hypothesis/
136
+ .pytest_cache/
137
+
138
+ # Translations
139
+ *.mo
140
+ *.pot
141
+
142
+ # Django stuff:
143
+ *.log
144
+ local_settings.py
145
+ db.sqlite3
146
+
147
+ # Flask stuff:
148
+ instance/
149
+ .webassets-cache
150
+
151
+ # Scrapy stuff:
152
+ .scrapy
153
+
154
+ # Sphinx documentation
155
+ docs/_build/
156
+
157
+ # PyBuilder
158
+ target/
159
+
160
+ # Jupyter Notebook
161
+ .ipynb_checkpoints
162
+
163
+ # IPython
164
+ profile_default/
165
+ ipython_config.py
166
+
167
+ # pyenv
168
+ .python-version
169
+
170
+ # celery beat schedule file
171
+ celerybeat-schedule
172
+
173
+ # SageMath parsed files
174
+ *.sage.py
175
+
176
+ # Environments
177
+ .env
178
+ .venv
179
+ env/
180
+ venv/
181
+ ENV/
182
+ env.bak/
183
+ venv.bak/
184
+
185
+ # Spyder project settings
186
+ .spyderproject
187
+ .spyproject
188
+
189
+ # Rope project settings
190
+ .ropeproject
191
+
192
+ # mkdocs documentation
193
+ /site
194
+
195
+ # mypy
196
+ .mypy_cache/
197
+ .dmypy.json
198
+ dmypy.json
199
+
200
+ # Pyre type checker
201
+ .pyre/
202
+
203
+ ### Python Patch ###
204
+ .venv/
205
+
206
+ # End of https://www.gitignore.io/api/python,pycharm
@@ -1,97 +1,94 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: PyBLNET
3
- Version: 0.9.4
3
+ Version: 0.10.0
4
4
  Summary: Automate wireless communication to UVR1611 via BL-NET
5
- Home-page: https://github.com/nielstron/pyblnet/
6
- Author: nielstron
7
- Author-email: n.muendler@web.de
8
- License: MIT
9
- Keywords: python uvr1611 blnet technische alternative home automation iot
5
+ Keywords: python,uvr1611,blnet,technische alternative,home automation,iot
6
+ Author-email: nielstron <n.muendler@posteo.de>
7
+ Requires-Python: >=3
8
+ Description-Content-Type: text/markdown
10
9
  Classifier: Development Status :: 4 - Beta
11
10
  Classifier: Intended Audience :: Developers
12
11
  Classifier: Topic :: Software Development :: Object Brokering
13
12
  Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3.4
15
- Classifier: Programming Language :: Python :: 3.5
16
- Classifier: Programming Language :: Python :: 3.6
17
- Classifier: Programming Language :: Python :: 3.7
18
13
  Classifier: Programming Language :: Python :: 3.8
19
14
  Classifier: Programming Language :: Python :: 3.9
20
15
  Classifier: Programming Language :: Python :: 3.10
21
16
  Classifier: Programming Language :: Python :: 3.11
22
- Requires-Python: >=3
23
- Description-Content-Type: text/markdown
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
24
19
  License-File: LICENSE.txt
25
20
  Requires-Dist: htmldom
26
21
  Requires-Dist: requests
22
+ Requires-Dist: pytest ; extra == "test"
23
+ Project-URL: Homepage, https://github.com/nielstron/pyblnet/
24
+ Provides-Extra: test
25
+
26
+ # PyBLNET - a very basic python BL-NET bridge
27
+ [![Build status](https://github.com/nielstron/pyblnet/actions/workflows/build.yml/badge.svg)](https://github.com/nielstron/pyblnet/actions/workflows/build.yml)
28
+ [![Coverage Status](https://coveralls.io/repos/github/nielstron/pyblnet/badge.svg?branch=master)](https://coveralls.io/github/nielstron/pyblnet?branch=master)
29
+
30
+ A package that connects to the BL-NET that is connected itself to a UVR1611 device by Technische Alternative.
31
+ It is able to read digital and analog values as well as to set switches to ON/OFF/AUTO.
32
+
33
+ Documentation on the modules and their methods can be found with the methods and modules themselves.
34
+
35
+ Two interfaces to BLNet exist and both are supported:
36
+ - Webinterface - Class BLnetWeb
37
+ - BLNet-Direct protocol [1] - Class BLNETDirect
38
+
39
+ However, as of now, there is no testing on the BLNet-Direct protocol *of any kind*, so enabling it is discouraged until the interface is fixed.
40
+ Parsing the data via the web interface is the preferred way of accessing the BLNet for now.
41
+
42
+ The class BLNET is a wrapper around the two classes. When initializing the class, the two interfaces can be activated/deactivated.
43
+ BLNetDirect provides 'analog', 'digital', 'speed', 'energy', 'power', whereas BLnetWeb supports 'analog' and 'digital' only.
44
+ If both are active, BLNetDirect has priority.
45
+ Setting switches and reading their manual/auto state is only possible via the BLNetWeb interface.
46
+
47
+ ### Usage
48
+
49
+ ```python
50
+ from pyblnet import blnet_test, BLNET, BLNETWeb, BLNETDirect
51
+
52
+ ip = '192.168.178.10'
53
+
54
+ # Check if there is a blnet at given address
55
+ blnet_test(ip) # -> True/False
56
+
57
+ # Convenient high level interface
58
+ blnet = BLNET(ip, password='pass', timeout=5)
59
+
60
+ # Control a switch by its ID
61
+ blnet.turn_on(10)
62
+ blnet.turn_auto(10)
63
+ blnet.turn_off(10)
64
+
65
+ # Fetch data (contains all available data using enabled interfaces)
66
+ print(blnet.fetch())
67
+
68
+ # The low level modules are also available
69
+ # note that the direct use of these modules is discouraged though
70
+
71
+ # Fetch the latest data via web interface
72
+ # Note that manual log in and log out are required
73
+ # when not using the with statement
74
+ with BLNETWeb(ip, password='pass', timeout=5) as blnet_session:
75
+ print(blnet_session.read_analog_values())
76
+ print(blnet_session.read_digital_values())
77
+
78
+ # For publishing values
79
+ blnet_session.set_digital_value('10', 'AUS')
80
+ # Note that without explicit log out,
81
+ # the BLNET will block any further web access for the next 150s
82
+ # this is handled automatically when using the with statement
83
+
84
+ # Fetch data via the Protocol developed by TA
85
+ blnet = BLNETDirect(ip)
86
+ # Fetching the latest data
87
+ print(blnet.get_latest())
88
+ # Still inofficial because unexplicably failing often
89
+ print(blnet._get_data(1))
90
+ ```
91
+
92
+
93
+ [1] https://www.haus-terra.at/heizung/download/Schnittstelle/Schnittstelle_PC_Bootloader.pdf
27
94
 
28
- # PyBLNET - a very basic python BL-NET bridge
29
- [![Build Status](https://app.travis-ci.com/nielstron/pyblnet.svg?branch=master)](https://app.travis-ci.com/github/nielstron/pyblnet)
30
- [![Coverage Status](https://coveralls.io/repos/github/nielstron/pyblnet/badge.svg?branch=master)](https://coveralls.io/github/nielstron/pyblnet?branch=master)
31
-
32
- A package that connects to the BL-NET that is connected itself to a UVR1611 device by Technische Alternative.
33
- It is able to read digital and analog values as well as to set switches to ON/OFF/AUTO.
34
-
35
- Documentation on the modules and their methods can be found with the methods and modules themselves.
36
-
37
- Two interfaces to BLNet exist and both are supported:
38
- - Webinterface - Class BLnetWeb
39
- - BLNet-Direct protocol [1] - Class BLNETDirect
40
-
41
- However, as of now, there is no testing on the BLNet-Direct protocol *of any kind*, so enabling it is discouraged until the interface is fixed.
42
- Parsing the data via the web interface is the preferred way of accessing the BLNet for now.
43
-
44
- The class BLNET is a wrapper around the two classes. When initializing the class, the two interfaces can be activated/deactivated.
45
- BLNetDirect provides 'analog', 'digital', 'speed', 'energy', 'power', whereas BLnetWeb supports 'analog' and 'digital' only.
46
- If both are active, BLNetDirect has priority.
47
- Setting switches and reading their manual/auto state is only possible via the BLNetWeb interface.
48
-
49
- ### Usage
50
-
51
- ```python
52
- from pyblnet import test_blnet, BLNET, BLNETWeb, BLNETDirect
53
-
54
- ip = '192.168.178.10'
55
-
56
- # Check if there is a blnet at given address
57
- test_blnet(ip) # -> True/False
58
-
59
- # Convenient high level interface
60
- blnet = BLNET(ip, password='pass', timeout=5)
61
-
62
- # Control a switch by its ID
63
- blnet.turn_on(10)
64
- blnet.turn_auto(10)
65
- blnet.turn_off(10)
66
-
67
- # Fetch data (contains all available data using enabled interfaces)
68
- print(blnet.fetch())
69
-
70
-
71
-
72
- # The low level modules are also available
73
- # note that the direct use of these modules is discouraged though
74
-
75
- # Fetch the latest data via web interface
76
- # Note that manual log in and log out are required
77
- # when not using the with statement
78
- with BLNETWeb(ip, password='pass', timeout=5) as blnet_session:
79
- print(blnet_session.read_analog_values())
80
- print(blnet_session.read_digital_values())
81
-
82
- # For publishing values
83
- blnet_session.set_digital_value('10', 'AUS')
84
- # Note that without explicit log out,
85
- # the BLNET will block any further web access for the next 150s
86
- # this is handled automatically when using the with statement
87
-
88
- # Fetch data via the Protocol developed by TA
89
- blnet = BLNETDirect(ip)
90
- # Fetching the latest data
91
- print(blnet.get_latest())
92
- # Still inofficial because unexplicably failing often
93
- print(blnet._get_data(1))
94
- ```
95
-
96
-
97
- [1] https://www.haus-terra.at/heizung/download/Schnittstelle/Schnittstelle_PC_Bootloader.pdf
pyblnet-0.10.0/Pipfile ADDED
@@ -0,0 +1,13 @@
1
+ [[source]]
2
+ url = "https://pypi.org/simple"
3
+ verify_ssl = true
4
+ name = "pypi"
5
+
6
+ [packages]
7
+ htmldom = "*"
8
+ requests = "*"
9
+
10
+ [dev-packages]
11
+
12
+ [requires]
13
+ python_version = "3.7"
@@ -1,5 +1,5 @@
1
1
  # PyBLNET - a very basic python BL-NET bridge
2
- [![Build Status](https://app.travis-ci.com/nielstron/pyblnet.svg?branch=master)](https://app.travis-ci.com/github/nielstron/pyblnet)
2
+ [![Build status](https://github.com/nielstron/pyblnet/actions/workflows/build.yml/badge.svg)](https://github.com/nielstron/pyblnet/actions/workflows/build.yml)
3
3
  [![Coverage Status](https://coveralls.io/repos/github/nielstron/pyblnet/badge.svg?branch=master)](https://coveralls.io/github/nielstron/pyblnet?branch=master)
4
4
 
5
5
  A package that connects to the BL-NET that is connected itself to a UVR1611 device by Technische Alternative.
@@ -22,12 +22,12 @@ Setting switches and reading their manual/auto state is only possible via the BL
22
22
  ### Usage
23
23
 
24
24
  ```python
25
- from pyblnet import test_blnet, BLNET, BLNETWeb, BLNETDirect
25
+ from pyblnet import blnet_test, BLNET, BLNETWeb, BLNETDirect
26
26
 
27
27
  ip = '192.168.178.10'
28
28
 
29
29
  # Check if there is a blnet at given address
30
- test_blnet(ip) # -> True/False
30
+ blnet_test(ip) # -> True/False
31
31
 
32
32
  # Convenient high level interface
33
33
  blnet = BLNET(ip, password='pass', timeout=5)
@@ -40,8 +40,6 @@ blnet.turn_off(10)
40
40
  # Fetch data (contains all available data using enabled interfaces)
41
41
  print(blnet.fetch())
42
42
 
43
-
44
-
45
43
  # The low level modules are also available
46
44
  # note that the direct use of these modules is discouraged though
47
45
 
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import warnings
5
+
6
+ try:
7
+ from .blnet_web import BLNETWeb, blnet_test
8
+ from .blnet_conn import BLNETDirect
9
+ from .blnet import BLNET
10
+ except ImportError as e:
11
+ warnings.warn(ImportWarning(e))
12
+
13
+ VERSION = (0, 10, 0)
14
+
@@ -9,7 +9,7 @@ https://github.com/berwinter/uvr1611/blob/master/lib/backend/blnet-connection.in
9
9
  @author: Niels
10
10
  """
11
11
  from builtins import str, int
12
- from socket import socket, getaddrinfo, SOCK_STREAM, IPPROTO_TCP
12
+ from socket import socket, getaddrinfo, SOCK_STREAM, IPPROTO_TCP, setdefaulttimeout
13
13
  import struct
14
14
  from time import sleep
15
15
  from datetime import datetime
@@ -41,12 +41,13 @@ class BLNETDirect(object):
41
41
  www.haus-terra.at/heizung/download/Schnittstelle/Schnittstelle_PC_Bootloader.pdf
42
42
  """
43
43
 
44
- def __init__(self, address, port=40000, reset=False):
44
+ def __init__(self, address, port: int = 40000, reset: bool = False, timeout: float = 60):
45
45
  """
46
46
  Constructor
47
- @param address: string, Address of the BL-Net device
48
- @param port: integer, Port of the bl-net device for connection
49
- @param reset: boolean, delete data on BL-Net after data receive
47
+ :param address: string, Address of the BL-Net device
48
+ :param port: integer, Port of the bl-net device for connection
49
+ :param reset: boolean, delete data on BL-Net after data receive
50
+ :param timeout: float, timeout in seconds for the connection
50
51
  """
51
52
  assert isinstance(address, str)
52
53
  assert isinstance(port, int)
@@ -58,6 +59,8 @@ class BLNETDirect(object):
58
59
  self._socket = None
59
60
  self._count = None
60
61
  self._check_mode()
62
+ if timeout:
63
+ setdefaulttimeout(timeout)
61
64
 
62
65
  def get_count(self):
63
66
  """
@@ -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
@@ -79,30 +79,18 @@ class BLNETParser:
79
79
  self.digital[channel + 1] = self._convert_digital(digital, channel)
80
80
 
81
81
  self.speed = {}
82
- for channel in range(0, 4):
83
- speed = self._convert_speed(speed[channel])
84
- if speed:
85
- self.speed[channel + 1] = round(speed, 3)
86
- else:
87
- break
82
+ for idx, value in enumerate(speed):
83
+ self.speed[idx + 1] = self._convert_speed(value)
88
84
 
89
85
  self.energy = {}
90
86
  for channel in range(0, 2):
91
87
  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
88
+ self.energy[channel + 1] = energy
96
89
 
97
90
  self.power = {}
98
- for channel in range(0, 2):
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
91
+ for idx, value in enumerate(power):
92
+ power = self._convert_power(value, active, idx)
93
+ self.power[idx + 1] = power
106
94
 
107
95
  def to_dict(self):
108
96
  """
@@ -149,7 +137,7 @@ class BLNETParser:
149
137
  if value & SPEED_ACTIVE:
150
138
  return None
151
139
  else:
152
- return value & SPEED_MASK
140
+ return round(value & SPEED_MASK, 3)
153
141
 
154
142
  def _convert_energy(self, mwh, kwh, active, position):
155
143
  """
@@ -158,7 +146,7 @@ class BLNETParser:
158
146
  """
159
147
  if active & position:
160
148
  kwh = self._calculate_value(kwh, 0.1, INT16_POSITIVE_MASK)
161
- return mwh * 1000 + kwh
149
+ return round(mwh * 1000 + kwh, 3)
162
150
  else:
163
151
  return None
164
152
 
@@ -168,12 +156,14 @@ class BLNETParser:
168
156
  @return its power
169
157
  """
170
158
  if active & position:
171
- return self._calculate_value(value, 1 / 2560, INT32_MASK, INT32_SIGN)
159
+ value = self._calculate_value(value, 1 / 2560, INT32_MASK, INT32_SIGN)
160
+ value = round(value, 3)
161
+ return value
172
162
  else:
173
163
  return None
174
164
 
175
165
  def _calculate_value(
176
- 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
177
167
  ):
178
168
  result = value & positive_mask
179
169
  if value & signbit:
@@ -16,7 +16,7 @@ import re
16
16
  from builtins import int
17
17
 
18
18
 
19
- def test_blnet(ip, timeout=5, id=0):
19
+ def blnet_test(ip, timeout=5, id=0):
20
20
  """
21
21
  Tests whether an BLNET answers under given ip
22
22
  Attributes:
@@ -63,7 +63,7 @@ class BLNETWeb(object):
63
63
  assert timeout is None or isinstance(timeout, int)
64
64
  if not ip.startswith("http://") and not ip.startswith("https://"):
65
65
  ip = "http://" + ip
66
- if not test_blnet(ip):
66
+ if not blnet_test(ip):
67
67
  raise ValueError("No BLNET found under given address: {}".format(ip))
68
68
  self.ip = ip
69
69
  self.password = password
@@ -0,0 +1,44 @@
1
+ [ build-system ]
2
+ requires = ["flit_core >=3.2,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [ project ]
6
+ name = "PyBLNET"
7
+ version = "0.10.0"
8
+ description = "Automate wireless communication to UVR1611 via BL-NET"
9
+ readme = "README.md"
10
+ readme-content-type = "text/markdown"
11
+ requires-python = ">=3"
12
+ license = {text = "MIT"}
13
+ authors = [
14
+ {name = "nielstron", email = "n.muendler@posteo.de"}
15
+ ]
16
+ homepage = "https://github.com/nielstron/pyblnet/"
17
+ keywords = ["python", "uvr1611", "blnet", "technische alternative", "home automation", "iot"]
18
+ classifiers = [
19
+ "Development Status :: 4 - Beta",
20
+ "Intended Audience :: Developers",
21
+ "Topic :: Software Development :: Object Brokering",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13"
29
+ ]
30
+ dependencies = [
31
+ "htmldom",
32
+ "requests",
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ test = [
37
+ "pytest",
38
+ ]
39
+
40
+ [ project.urls ]
41
+ "Homepage" = "https://github.com/nielstron/pyblnet/"
42
+
43
+ [ tool.flit.module ]
44
+ name = "pyblnet"
@@ -11,12 +11,16 @@ class TestParser(unittest.TestCase):
11
11
  expected_values = {
12
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
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': {}
14
+ 'speed': {1: None, 2: 0, 3: 0, 4: 0},
15
+ 'energy': {1: None, 2: None},
16
+ 'power': {1: None, 2: None}
17
17
  }
18
18
 
19
- assert parsed_values == expected_values
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']
20
24
 
21
25
  def test_parser_not_ok(self):
22
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'
@@ -0,0 +1,10 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="content-type" content="text/html; charset=windows-1252">
4
+ <title>BL-Net Zugang verweigert</title></head>
5
+ <body bgcolor="#EEEEEE"><font size="5">Sie sind nicht befugt auf diese Seite zuzugreifen!!!<br>
6
+ <script type="text/javascript">
7
+ if(document.URL!=window.top.location.href){ window.top.document.getElementById('outd').style.display='none';window.top.document.getElementById('ind').style.display='block';window.top.document.getElementById('logu').style.display='none';}
8
+ </script>
9
+ </font></body>
10
+ </html>
@@ -3,15 +3,15 @@
3
3
 
4
4
  # general requirements
5
5
  import unittest
6
- from .test_structure.server_control import Server
7
- from .test_structure.blnet_mock_server import BLNETServer, BLNETRequestHandler, PASSWORD
6
+ from tests.test_structure.server_control import Server
7
+ from tests.test_structure.blnet_mock_server import BLNETServer, BLNETRequestHandler, PASSWORD
8
8
 
9
9
  # For the server in this case
10
10
  import time
11
11
 
12
12
  # For the tests
13
- from .. import BLNET, test_blnet, BLNETWeb
14
- from .web_raw.web_state import STATE, STATE_ANALOG, STATE_DIGITAL
13
+ from pyblnet import BLNET, blnet_test, BLNETWeb
14
+ from tests.web_raw.web_state import STATE, STATE_ANALOG, STATE_DIGITAL
15
15
 
16
16
  ADDRESS = "localhost"
17
17
 
@@ -22,7 +22,7 @@ class OfflineTest(unittest.TestCase):
22
22
 
23
23
  def test_blnet(self):
24
24
  """Test finding the blnet"""
25
- self.assertFalse(test_blnet(self.url, timeout=10))
25
+ self.assertFalse(blnet_test(self.url, timeout=10))
26
26
 
27
27
  def test_blnet_web(self):
28
28
  try:
@@ -66,9 +66,9 @@ class BLNETWebTest(unittest.TestCase):
66
66
 
67
67
  def test_blnet(self):
68
68
  """Test finding the blnet"""
69
- self.assertTrue(test_blnet(self.url, timeout=10))
69
+ self.assertTrue(blnet_test(self.url, timeout=10))
70
70
  self.server.set_blocked()
71
- self.assertTrue(test_blnet(self.url, timeout=10))
71
+ self.assertTrue(blnet_test(self.url, timeout=10))
72
72
 
73
73
  def test_blnet_web_log_in(self):
74
74
  """
Binary file
@@ -1,97 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: PyBLNET
3
- Version: 0.9.4
4
- Summary: Automate wireless communication to UVR1611 via BL-NET
5
- Home-page: https://github.com/nielstron/pyblnet/
6
- Author: nielstron
7
- Author-email: n.muendler@web.de
8
- License: MIT
9
- Keywords: python uvr1611 blnet technische alternative home automation iot
10
- Classifier: Development Status :: 4 - Beta
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Topic :: Software Development :: Object Brokering
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3.4
15
- Classifier: Programming Language :: Python :: 3.5
16
- Classifier: Programming Language :: Python :: 3.6
17
- Classifier: Programming Language :: Python :: 3.7
18
- Classifier: Programming Language :: Python :: 3.8
19
- Classifier: Programming Language :: Python :: 3.9
20
- Classifier: Programming Language :: Python :: 3.10
21
- Classifier: Programming Language :: Python :: 3.11
22
- Requires-Python: >=3
23
- Description-Content-Type: text/markdown
24
- License-File: LICENSE.txt
25
- Requires-Dist: htmldom
26
- Requires-Dist: requests
27
-
28
- # PyBLNET - a very basic python BL-NET bridge
29
- [![Build Status](https://app.travis-ci.com/nielstron/pyblnet.svg?branch=master)](https://app.travis-ci.com/github/nielstron/pyblnet)
30
- [![Coverage Status](https://coveralls.io/repos/github/nielstron/pyblnet/badge.svg?branch=master)](https://coveralls.io/github/nielstron/pyblnet?branch=master)
31
-
32
- A package that connects to the BL-NET that is connected itself to a UVR1611 device by Technische Alternative.
33
- It is able to read digital and analog values as well as to set switches to ON/OFF/AUTO.
34
-
35
- Documentation on the modules and their methods can be found with the methods and modules themselves.
36
-
37
- Two interfaces to BLNet exist and both are supported:
38
- - Webinterface - Class BLnetWeb
39
- - BLNet-Direct protocol [1] - Class BLNETDirect
40
-
41
- However, as of now, there is no testing on the BLNet-Direct protocol *of any kind*, so enabling it is discouraged until the interface is fixed.
42
- Parsing the data via the web interface is the preferred way of accessing the BLNet for now.
43
-
44
- The class BLNET is a wrapper around the two classes. When initializing the class, the two interfaces can be activated/deactivated.
45
- BLNetDirect provides 'analog', 'digital', 'speed', 'energy', 'power', whereas BLnetWeb supports 'analog' and 'digital' only.
46
- If both are active, BLNetDirect has priority.
47
- Setting switches and reading their manual/auto state is only possible via the BLNetWeb interface.
48
-
49
- ### Usage
50
-
51
- ```python
52
- from pyblnet import test_blnet, BLNET, BLNETWeb, BLNETDirect
53
-
54
- ip = '192.168.178.10'
55
-
56
- # Check if there is a blnet at given address
57
- test_blnet(ip) # -> True/False
58
-
59
- # Convenient high level interface
60
- blnet = BLNET(ip, password='pass', timeout=5)
61
-
62
- # Control a switch by its ID
63
- blnet.turn_on(10)
64
- blnet.turn_auto(10)
65
- blnet.turn_off(10)
66
-
67
- # Fetch data (contains all available data using enabled interfaces)
68
- print(blnet.fetch())
69
-
70
-
71
-
72
- # The low level modules are also available
73
- # note that the direct use of these modules is discouraged though
74
-
75
- # Fetch the latest data via web interface
76
- # Note that manual log in and log out are required
77
- # when not using the with statement
78
- with BLNETWeb(ip, password='pass', timeout=5) as blnet_session:
79
- print(blnet_session.read_analog_values())
80
- print(blnet_session.read_digital_values())
81
-
82
- # For publishing values
83
- blnet_session.set_digital_value('10', 'AUS')
84
- # Note that without explicit log out,
85
- # the BLNET will block any further web access for the next 150s
86
- # this is handled automatically when using the with statement
87
-
88
- # Fetch data via the Protocol developed by TA
89
- blnet = BLNETDirect(ip)
90
- # Fetching the latest data
91
- print(blnet.get_latest())
92
- # Still inofficial because unexplicably failing often
93
- print(blnet._get_data(1))
94
- ```
95
-
96
-
97
- [1] https://www.haus-terra.at/heizung/download/Schnittstelle/Schnittstelle_PC_Bootloader.pdf
@@ -1,27 +0,0 @@
1
- LICENSE.txt
2
- README.md
3
- setup.py
4
- PyBLNET.egg-info/PKG-INFO
5
- PyBLNET.egg-info/SOURCES.txt
6
- PyBLNET.egg-info/dependency_links.txt
7
- PyBLNET.egg-info/requires.txt
8
- PyBLNET.egg-info/top_level.txt
9
- pyblnet/__init__.py
10
- pyblnet/blnet.py
11
- pyblnet/blnet_conn.py
12
- pyblnet/blnet_parser.py
13
- pyblnet/blnet_web.py
14
- pyblnet/tests/__init__.py
15
- pyblnet/tests/test_parser.py
16
- pyblnet/tests/test_web.py
17
- pyblnet/tests/test_structure/580500.alternative.htm
18
- pyblnet/tests/test_structure/580500.htm
19
- pyblnet/tests/test_structure/580600.htm
20
- pyblnet/tests/test_structure/__init__.py
21
- pyblnet/tests/test_structure/blnet_mock_server.py
22
- pyblnet/tests/test_structure/main.htm
23
- pyblnet/tests/test_structure/main.html
24
- pyblnet/tests/test_structure/par.htm
25
- pyblnet/tests/test_structure/server_control.py
26
- pyblnet/tests/web_raw/__init__.py
27
- pyblnet/tests/web_raw/web_state.py
@@ -1,2 +0,0 @@
1
- htmldom
2
- requests
@@ -1 +0,0 @@
1
- pyblnet
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- import warnings
5
-
6
- try:
7
- from .blnet_web import BLNETWeb, test_blnet
8
- from .blnet_conn import BLNETDirect
9
- from .blnet import BLNET
10
- except ImportError as e:
11
- warnings.warn(ImportWarning(e))
12
-
13
- VERSION = (0, 9, 4)
14
-
15
- __version__ = ".".join([str(i) for i in VERSION])
16
- __author__ = "nielstron"
17
- __author_email__ = "n.muendler@web.de"
18
- __copyright__ = "Copyright (C) 2019 nielstron"
19
- __license__ = "MIT"
20
- __url__ = "https://github.com/nielstron/pyblnet"
pyblnet-0.9.4/setup.cfg DELETED
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
pyblnet-0.9.4/setup.py DELETED
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- from setuptools import setup, find_packages
5
-
6
- # To use a consistent encoding
7
- from codecs import open
8
- from os import path
9
-
10
- import pyblnet
11
-
12
- here = path.abspath(path.dirname(__file__))
13
-
14
- # Get the long description from the README file
15
- with open(path.join(here, "README.md"), encoding="utf-8") as f:
16
- long_description = f.read()
17
-
18
- setup(
19
- name="PyBLNET",
20
- version=pyblnet.__version__,
21
- description="Automate wireless communication to UVR1611 via BL-NET",
22
- author=pyblnet.__author__,
23
- author_email=pyblnet.__author_email__,
24
- url="https://github.com/nielstron/pyblnet/",
25
- py_modules=["pyblnet"],
26
- packages=find_packages(),
27
- package_data={"": ["*.html", "*.htm"]},
28
- install_requires=["htmldom", "requests"],
29
- long_description=long_description,
30
- long_description_content_type="text/markdown",
31
- license=pyblnet.__license__,
32
- classifiers=[
33
- "Development Status :: 4 - Beta",
34
- # Indicate who your project is intended for
35
- "Intended Audience :: Developers",
36
- "Topic :: Software Development :: Object Brokering",
37
- # Pick your license as you wish (should match "license" above)
38
- "License :: OSI Approved :: MIT License",
39
- # Specify the Python versions you support here. In particular, ensure
40
- # that you indicate whether you support Python 2, Python 3 or both.
41
- "Programming Language :: Python :: 3.4",
42
- "Programming Language :: Python :: 3.5",
43
- "Programming Language :: Python :: 3.6",
44
- "Programming Language :: Python :: 3.7",
45
- "Programming Language :: Python :: 3.8",
46
- "Programming Language :: Python :: 3.9",
47
- "Programming Language :: Python :: 3.10",
48
- "Programming Language :: Python :: 3.11",
49
- ],
50
- keywords="python uvr1611 blnet technische alternative home automation iot",
51
- python_requires=">=3",
52
- test_suite="pyblnet.tests",
53
- )
File without changes
File without changes