Skip to content

Commit 1da602d

Browse files
authored
Merge pull request #6 from ThyMYthOS/master
Update pymodbus and python dependencies
2 parents 536367f + 3ba7daa commit 1da602d

File tree

10 files changed

+87
-105
lines changed

10 files changed

+87
-105
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test python package
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
python-version: ["3.12", "3.13"]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Install dependencies
24+
run: pip install tox
25+
- name: Run tests
26+
run: tox

.travis.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
</p>
44
<p align=center>
55
<a href="https://pypi.org/project/pystiebeleltron/"><img src="https://img.shields.io/pypi/v/pystiebeleltron.svg"/></a>
6-
<a href="https://travis-ci.org/fucm/python-stiebel-eltron"><img src="https://img.shields.io/travis/fucm/python-stiebel-eltron.svg"/></a>
7-
<a href='https://coveralls.io/github/fucm/python-stiebel-eltron?branch=master'><img src='https://coveralls.io/repos/github/fucm/python-stiebel-eltron/badge.svg?branch=master' alt='Coverage Status' /></a>
8-
<img src="https://img.shields.io/github/license/fucm/python-stiebel-eltron.svg"/></a>
6+
<a href="https://github.com/ThyMYthOS/python-stiebel-eltron/actions/workflows/test-python-package.yml"><img src="https://github.com/ThyMYthOS/python-stiebel-eltron/actions/workflows/test-python-package.yml/badge.svg"/></a>
7+
<!--a href='https://coveralls.io/github/fucm/python-stiebel-eltron?branch=master'><img src='https://coveralls.io/repos/github/fucm/python-stiebel-eltron/badge.svg?branch=master' alt='Coverage Status' /></a>
8+
<img src="https://img.shields.io/github/license/ThyMYthOS/python-stiebel-eltron.svg"/></a Maybe use https://github.com/marketplace/actions/coverage-badge-->
99
</p>
1010

1111
# python-stiebel-eltron
@@ -42,9 +42,9 @@ The sample below shows how to use this Python module.
4242

4343
unit = pyse.StiebelEltronAPI(client, 1)
4444
unit.update()
45-
45+
4646
print("get_target_temp: {}".format(unit.get_target_temp))
47-
47+
4848
client.close()
4949
```
5050

example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
import time
33
from pystiebeleltron import pystiebeleltron as pyse
4-
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
4+
from pymodbus.client import ModbusTcpClient as ModbusClient
55

66
host_ip = "192.168.1.20"
77
host_port = 502

pystiebeleltron/pystiebeleltron.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
8 | 0 to 255 | 1 | 1 | No | 1 | 5
1818
"""
1919

20+
from pymodbus.client.mixin import ModbusClientMixin
21+
2022
# Error - sensor lead is missing or disconnected.
2123
ERROR_NOTAVAILABLE = -60
2224
# Error - short circuit of the sensor lead.
@@ -176,7 +178,7 @@
176178
class StiebelEltronAPI():
177179
"""Stiebel Eltron API."""
178180

179-
def __init__(self, conn, slave, update_on_read=False):
181+
def __init__(self, conn: ModbusClientMixin, slave=1, update_on_read=False):
180182
"""Initialize Stiebel Eltron communication."""
181183
self._conn = conn
182184
self._block_1_input_regs = B1_REGMAP_INPUT
@@ -190,40 +192,34 @@ def update(self):
190192
ret = True
191193
try:
192194
block_1_result_input = self._conn.read_input_registers(
193-
unit=self._slave,
195+
slave=self._slave,
194196
address=B1_START_ADDR,
195197
count=len(self._block_1_input_regs)).registers
196198
block_2_result_holding = self._conn.read_holding_registers(
197-
unit=self._slave,
199+
slave=self._slave,
198200
address=B2_START_ADDR,
199201
count=len(self._block_2_holding_regs)).registers
200202
block_3_result_input = self._conn.read_input_registers(
201-
unit=self._slave,
203+
slave=self._slave,
202204
address=B3_START_ADDR,
203205
count=len(self._block_3_input_regs)).registers
204206
except AttributeError:
205207
# The unit does not reply reliably
206208
ret = False
207209
print("Modbus read failed")
208210
else:
209-
for k in self._block_1_input_regs:
210-
self._block_1_input_regs[k]['value'] = \
211-
block_1_result_input[
212-
self._block_1_input_regs[k]['addr'] - B1_START_ADDR]
211+
for v in self._block_1_input_regs.values():
212+
v['value'] = block_1_result_input[v['addr'] - B1_START_ADDR]
213213

214-
for k in self._block_2_holding_regs:
215-
self._block_2_holding_regs[k]['value'] = \
216-
block_2_result_holding[
217-
self._block_2_holding_regs[k]['addr'] - B2_START_ADDR]
214+
for v in self._block_2_holding_regs.values():
215+
v['value'] = block_2_result_holding[v['addr'] - B2_START_ADDR]
218216

219-
for k in self._block_3_input_regs:
220-
self._block_3_input_regs[k]['value'] = \
221-
block_3_result_input[
222-
self._block_3_input_regs[k]['addr'] - B3_START_ADDR]
217+
for v in self._block_3_input_regs.values():
218+
v['value'] = block_3_result_input[v['addr'] - B3_START_ADDR]
223219

224220
return ret
225221

226-
def get_conv_val(self, name):
222+
def get_conv_val(self, name: str):
227223
"""Read and convert value.
228224
229225
Args:
@@ -262,7 +258,7 @@ def get_conv_val(self, name):
262258
# def set_raw_holding_register(self, name, value):
263259
# """Write to register by name."""
264260
# self._conn.write_register(
265-
# unit=self._slave,
261+
# slave=self._slave,
266262
# address=(self._holding_regs[name]['addr']),
267263
# value=value)
268264

@@ -280,10 +276,10 @@ def get_target_temp(self):
280276
self.update()
281277
return self.get_conv_val('ROOM_TEMP_HEAT_DAY_HC1')
282278

283-
def set_target_temp(self, temp):
279+
def set_target_temp(self, temp: float):
284280
"""Set the target room temperature (day)(HC1)."""
285281
self._conn.write_register(
286-
unit=self._slave,
282+
slave=self._slave,
287283
address=(
288284
self._block_2_holding_regs['ROOM_TEMP_HEAT_DAY_HC1']['addr']),
289285
value=round(temp * 10.0))
@@ -304,10 +300,10 @@ def get_operation(self):
304300
op_mode = self.get_conv_val('OPERATING_MODE')
305301
return B2_OPERATING_MODE_READ.get(op_mode, 'UNKNOWN')
306302

307-
def set_operation(self, mode):
303+
def set_operation(self, mode: str):
308304
"""Set the operation mode."""
309305
self._conn.write_register(
310-
unit=self._slave,
306+
slave=self._slave,
311307
address=(self._block_2_holding_regs['OPERATING_MODE']['addr']),
312308
value=B2_OPERATING_MODE_WRITE.get(mode))
313309

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pymodbus>=2.1.0
1+
pymodbus>=3.1.0

setup.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ def run_tests(self):
3737

3838
setup(
3939
name='pystiebeleltron',
40-
version='0.0.1.dev2',
40+
version='0.1.1',
4141
description='Python API for interacting with the Stiebel Eltron ISG web gateway via Modbus for controlling integral ventilation units and heat pumps.',
4242
long_description=long_description,
4343
long_description_content_type='text/markdown',
44-
url='https://github.com/fucm/python-stiebel-eltron',
45-
author='Martin Fuchs',
44+
url='https://github.com/ThyMYthOS/python-stiebel-eltron',
45+
author='Martin Fuchs, Manuel Stahl',
4646
license='MIT',
47-
python_requires='>=3.4',
48-
install_requires=['pymodbus>=2.1.0'],
47+
python_requires='>=3.8',
48+
install_requires=['pymodbus>=3.1.0'],
4949
tests_require=['tox'],
5050
cmdclass={'test': Tox},
5151
packages=find_packages(exclude=('test', 'test.*')),
@@ -56,9 +56,12 @@ def run_tests(self):
5656
'Development Status :: 3 - Alpha',
5757
'Intended Audience :: Developers',
5858
'License :: OSI Approved :: MIT License',
59-
'Programming Language :: Python :: 3.4',
60-
'Programming Language :: Python :: 3.5',
61-
'Programming Language :: Python :: 3.6',
59+
'Programming Language :: Python :: 3.8',
60+
'Programming Language :: Python :: 3.9',
61+
'Programming Language :: Python :: 3.10',
62+
'Programming Language :: Python :: 3.11',
63+
'Programming Language :: Python :: 3.12',
64+
'Programming Language :: Python :: 3.13',
6265
'Topic :: Utilities',
6366
],
6467
)

test/mock_modbus_server.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
twisted library as its backend. This allows it to scale to many thousands
88
of nodes which can be helpful for testing monitoring software.
99
"""
10-
# --------------------------------------------------------------------------- #
10+
# --------------------------------------------------------------------------- #
1111
# import the various server implementations
12-
# --------------------------------------------------------------------------- #
13-
from pymodbus.server.async import StartTcpServer, StopServer
12+
# --------------------------------------------------------------------------- #
13+
from pymodbus.server import StartTcpServer, ServerStop
1414

1515
from pymodbus.device import ModbusDeviceIdentification
1616
from pymodbus.datastore import ModbusSequentialDataBlock
1717
from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext
1818

1919

2020
class MockModbusServer(object):
21-
# --------------------------------------------------------------------------- #
21+
# --------------------------------------------------------------------------- #
2222
# configure the service logging
23-
# --------------------------------------------------------------------------- #
23+
# --------------------------------------------------------------------------- #
2424
import logging
2525
FORMAT = ('%(asctime)-15s %(threadName)-15s'
2626
' %(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
@@ -29,9 +29,9 @@ class MockModbusServer(object):
2929
log.setLevel(logging.DEBUG)
3030

3131
def run_async_server(self):
32-
# ----------------------------------------------------------------------- #
32+
# ----------------------------------------------------------------------- #
3333
# initialize your data store
34-
# ----------------------------------------------------------------------- #
34+
# ----------------------------------------------------------------------- #
3535
# The datastores only respond to the addresses that they are initialized to
3636
# Therefore, if you initialize a DataBlock to addresses from 0x00 to 0xFF,
3737
# a request to 0x100 will respond with an invalid address exception.
@@ -82,17 +82,17 @@ def run_async_server(self):
8282
# will map to (1-8)::
8383
#
8484
# store = ModbusSlaveContext(..., zero_mode=True)
85-
# ----------------------------------------------------------------------- #
85+
# ----------------------------------------------------------------------- #
8686
store = ModbusSlaveContext(
8787
hr=ModbusSequentialDataBlock(0, [0]*3000),
8888
ir=ModbusSequentialDataBlock(0, [0]*3000))
8989
self.context = ModbusServerContext(slaves=store, single=True)
9090

91-
# ----------------------------------------------------------------------- #
91+
# ----------------------------------------------------------------------- #
9292
# initialize the server information
93-
# ----------------------------------------------------------------------- #
93+
# ----------------------------------------------------------------------- #
9494
# If you don't set this or any fields, they are defaulted to empty strings.
95-
# ----------------------------------------------------------------------- #
95+
# ----------------------------------------------------------------------- #
9696
identity = ModbusDeviceIdentification()
9797
identity.VendorName = 'Pymodbus'
9898
identity.ProductCode = 'PM'
@@ -101,15 +101,15 @@ def run_async_server(self):
101101
identity.ModelName = 'Pymodbus Server'
102102
identity.MajorMinorRevision = '1.5'
103103

104-
# ----------------------------------------------------------------------- #
104+
# ----------------------------------------------------------------------- #
105105
# run the server you want
106-
# ----------------------------------------------------------------------- #
106+
# ----------------------------------------------------------------------- #
107107

108108
# TCP Server
109109
StartTcpServer(self.context, identity=identity, address=("localhost", 5020))
110110

111111
def stop_async_server(self):
112-
StopServer()
112+
ServerStop()
113113

114114
def update_context(self, register, address, values):
115115
""" Update values of the active context. It should be noted

test/test_pystiebeleltron.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from test.mock_modbus_server import MockModbusServer as ModbusServer
99

1010
# Import client requirementss
11-
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
11+
from pymodbus.client import ModbusTcpClient as ModbusClient
1212
from pystiebeleltron import pystiebeleltron as pyse
1313

1414
# Modbus server connection details

0 commit comments

Comments
 (0)