Skip to content

Commit 7733cfc

Browse files
committed
Update pymodbus and python dependencies
1 parent 536367f commit 7733cfc

File tree

7 files changed

+47
-46
lines changed

7 files changed

+47
-46
lines changed

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: 12 additions & 10 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,15 +192,15 @@ 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:
@@ -223,7 +225,7 @@ def update(self):
223225

224226
return ret
225227

226-
def get_conv_val(self, name):
228+
def get_conv_val(self, name: str):
227229
"""Read and convert value.
228230
229231
Args:
@@ -262,7 +264,7 @@ def get_conv_val(self, name):
262264
# def set_raw_holding_register(self, name, value):
263265
# """Write to register by name."""
264266
# self._conn.write_register(
265-
# unit=self._slave,
267+
# slave=self._slave,
266268
# address=(self._holding_regs[name]['addr']),
267269
# value=value)
268270

@@ -280,10 +282,10 @@ def get_target_temp(self):
280282
self.update()
281283
return self.get_conv_val('ROOM_TEMP_HEAT_DAY_HC1')
282284

283-
def set_target_temp(self, temp):
285+
def set_target_temp(self, temp: float):
284286
"""Set the target room temperature (day)(HC1)."""
285287
self._conn.write_register(
286-
unit=self._slave,
288+
slave=self._slave,
287289
address=(
288290
self._block_2_holding_regs['ROOM_TEMP_HEAT_DAY_HC1']['addr']),
289291
value=round(temp * 10.0))
@@ -304,10 +306,10 @@ def get_operation(self):
304306
op_mode = self.get_conv_val('OPERATING_MODE')
305307
return B2_OPERATING_MODE_READ.get(op_mode, 'UNKNOWN')
306308

307-
def set_operation(self, mode):
309+
def set_operation(self, mode: str):
308310
"""Set the operation mode."""
309311
self._conn.write_register(
310-
unit=self._slave,
312+
slave=self._slave,
311313
address=(self._block_2_holding_regs['OPERATING_MODE']['addr']),
312314
value=B2_OPERATING_MODE_WRITE.get(mode))
313315

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: 9 additions & 6 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.0',
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',
4444
url='https://github.com/fucm/python-stiebel-eltron',
4545
author='Martin Fuchs',
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

tox.ini

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# directory.
55

66
[tox]
7-
envlist = py34,py35,py36,py37,py38,py39,flake8,pylint,refactory
7+
envlist = py38,py39,py310,py311,py312,py313,flake8,pylint,refactory
88
skip_missing_interpreters = true
99

1010
[testenv]
@@ -18,7 +18,7 @@ commands =
1818
pytest
1919

2020
[testenv:py38]
21-
deps =
21+
deps =
2222
pytest
2323
pytest-cov
2424
coverage
@@ -27,15 +27,15 @@ commands =
2727
pytest --cov=pystiebeleltron --cov-report term {posargs}
2828

2929
[testenv:pylint]
30-
deps =
30+
deps =
3131
pylint
32-
commands =
32+
commands =
3333
pylint --rcfile=tox.ini pystiebeleltron
3434

3535
[testenv:flake8]
36-
deps =
36+
deps =
3737
flake8
38-
commands =
38+
commands =
3939
flake8 pystiebeleltron
4040
#norecursedirs=.tox .git venv
4141
#ignore = E226
@@ -44,9 +44,9 @@ commands =
4444
exclude = .tox
4545

4646
[testenv:refactory]
47-
deps =
47+
deps =
4848
pylint
49-
commands =
49+
commands =
5050
pylint -d all -e CR pystiebeleltron
5151

5252
[testenv:coverage]
@@ -63,12 +63,8 @@ commands =
6363
# for travis-ci configuration
6464
[travis]
6565
python =
66-
3.4: py34
67-
3.5: py35
68-
3.6: py36
69-
3.7: py37
7066
3.8: py38, flake8, pylint, coverage
71-
3.9-dev: py39
67+
3.9: py39
7268

7369
# .coveragerc to control coverage.py
7470
[report]

0 commit comments

Comments
 (0)