Skip to content

Commit b6c27ab

Browse files
committed
Fix Python module, add example
1 parent 82eee6e commit b6c27ab

File tree

4 files changed

+82
-6
lines changed

4 files changed

+82
-6
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
106+
# ------------------------------------------
107+
# Visual Studio Code
108+
.vscode/*

example.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python3
2+
import time
3+
from pystiebeleltron import pystiebeleltron as pyse
4+
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
5+
6+
host_ip = "192.168.1.20"
7+
host_port = 502
8+
slave = 1
9+
10+
def test_function(mod, fun):
11+
"""Executes the given function on the Stiebel Heatpump and prints the result."""
12+
result = getattr(mod, fun) # Executes function directly, instead of giving back the function reference
13+
print("{}: {}".format(str(fun), str(result)))
14+
15+
16+
def execute_tests(unit):
17+
"""Execute the provided tests."""
18+
test_function(unit, "get_current_temp")
19+
test_function(unit, "get_target_temp")
20+
test_function(unit, "get_operation")
21+
test_function(unit, "get_filter_alarm")
22+
23+
if False:
24+
print("unit.get_fan_speed {}".format(unit.get_fan_speed))
25+
print("unit.get_heat_recovery {}".format(unit.get_heat_recovery))
26+
print("unit.get_heating {}".format(unit.get_heating))
27+
print("unit.get_heater_enabled {}".format(unit.get_heater_enabled))
28+
print("unit.get_cooling {}".format(unit.get_cooling))
29+
print("unit.get_filter_alarm {}".format(unit.get_filter_alarm))
30+
31+
32+
print("Setting fan to 3")
33+
unit.set_fan_speed(3)
34+
time.sleep(3)
35+
unit.update()
36+
print("unit.get_fan_speed {}".format(unit.get_fan_speed))
37+
38+
print("Setting fan to 2")
39+
unit.set_fan_speed(2)
40+
time.sleep(3)
41+
unit.update()
42+
print("unit.get_fan_speed {}".format(unit.get_fan_speed))
43+
44+
print("Setting fan to 3 with set_raw_holding_register()")
45+
unit.set_raw_holding_register('SetAirSpeed', 3)
46+
time.sleep(2)
47+
unit.update()
48+
print("unit.get_fan_speed {}".format(unit.get_fan_speed))
49+
50+
print("Setting fan to 2 with set_raw_holding_register()")
51+
unit.set_raw_holding_register('SetAirSpeed', 2)
52+
time.sleep(2)
53+
unit.update()
54+
print("unit.get_fan_speed {}".format(unit.get_fan_speed))
55+
56+
57+
def main():
58+
client = ModbusClient(host=host_ip,
59+
port=host_port,
60+
timeout=2)
61+
client.connect()
62+
63+
unit = pyse.StiebelEltronAPI(client, slave)
64+
unit.update()
65+
66+
execute_tests(unit)
67+
68+
client.close()
69+
70+
if __name__ is "__main__":
71+
main()

pystiebeleltron/pystiebeleltron.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173

174174

175175
class StiebelEltronAPI(object):
176-
"""API object."""
176+
"""Stiebel Eltron API."""
177177

178178
def __init__(self, conn, slave, update_on_read=False):
179179
"""Initialize Stiebel Eltron communication."""
@@ -195,6 +195,7 @@ def __init__(self, conn, slave, update_on_read=False):
195195
self._alarm = False
196196
self._update_on_read = update_on_read
197197

198+
198199
def update(self):
199200
"""Request current values from heat pump."""
200201
ret = True
@@ -322,14 +323,14 @@ def get_conv_val(self, name):
322323

323324
@property
324325
def get_current_temp(self):
325-
"""Get the current temperature."""
326+
"""Get the current room temperature."""
326327
if self._update_on_read:
327328
self.update()
328329
return self._current_temp
329330

330331
@property
331332
def get_target_temp(self):
332-
"""Get target temperature."""
333+
"""Get the target room temperature."""
333334
if self._update_on_read:
334335
self.update()
335336
return self._target_temp

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2018 Martin Fuchs <mail-addr>
2+
Copyright (c) 2018 Martin Fuchs <[email protected]>
33
Licensed under MIT. All rights reserved.
44
"""
55
import os
@@ -23,13 +23,13 @@
2323
long_description=long_description,
2424
url='https://github.com/fucm/python-stiebel-eltron',
2525
author='Martin Fuchs',
26-
author_email='mail-addrr',
26+
author_email='[email protected]',
2727
license='MIT',
2828
install_requires=[],
2929
packages=find_packages(),
3030
zip_safe=True,
3131
include_package_data=True,
32-
""" https://pypi.org/classifiers/ """
32+
# https://pypi.org/classifiers/
3333
classifiers=[
3434
'Development Status :: 3 - Alpha',
3535
'Environment :: Console',

0 commit comments

Comments
 (0)