Spanni26 / pyHPSU

Python Script to read and send commands to a Rotex HPSU
26 stars 15 forks source link

Output Adapter MQTT #23

Closed adieball closed 3 years ago

adieball commented 5 years ago

Hi

when using the new (Beta) MQTT Adapter, I get:

pi@can:~/pyHPSU/plugins $ pyHPSU.py -c water_pressure -o mqtt Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in <module> main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 331, in read_can hpsu_plugin = module.export(hpsu=n_hpsu, logger=logger, config_file=conf_file) File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 77, in __init__ if self.username: AttributeError: 'export' object has no attribute 'username' pi@can:~/pyHPSU/plugins $

adieball commented 5 years ago

My Fault, I edited the wrong MQTT.py file.

Now I get pi@can:~/pyHPSU/plugins $ pyHPSU.py -c water_pressure -o mqtt Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in <module> main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 332, in read_can hpsu_plugin.pushValues(vars=arrResponse) File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 94, in pushValues ret=self.client.publish(self.prefix + "/" + r['name'],payload=r['resp'], qos=self.qos) File "/home/pi/.local/lib/python3.5/site-packages/paho/mqtt/client.py", line 1136, in publish if qos < 0 or qos > 2: TypeError: unorderable types: str() < int() pi@can:~/pyHPSU/plugins $

On the MQTT Adapter I can see that rotes connected with the secret but nothing else

Spanni26 commented 5 years ago

Should be fixed.

adieball commented 4 years ago

Hi. Have you fixed based on the comments I made for the Mqtt.py files

Spanni26 commented 4 years ago

Hmmm....was a while ago :) Don't know.

jockele79 commented 4 years ago

Hello everybody,

I just set up a raspi 3 and have the same problem:

root@raspberrypi:~# pyHPSU.py -c t_hs -o mqtt Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in <module> main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 330, in read_can module = importlib.import_module("HPSU.plugins." + module_name) File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 18, in <modul e> import paho.mqtt.publish as publish ModuleNotFoundError: No module named 'paho'

Does anyone have a solution for this problem?

Spanni26 commented 4 years ago

Moin, thy python module "phao" is missing, its needed for mqtt.RegardsDanielAm 28.03.2020 06:37 schrieb jockele79 notifications@github.com: Hello everybody, I just set up a raspi 3 and have the same problem: root@raspberrypi:~# pyHPSU.py -c t_hs -o mqtt Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 330, in read_can module = importlib.import_module("HPSU.plugins." + module_name) File "/usr/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 18, in import paho.mqtt.publish as publish ModuleNotFoundError: No module named 'paho' Does anyone have a solution for this problem?

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.

jockele79 commented 4 years ago

pi@raspberrypi:~ $ sudo pip install paho-mqtt Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: paho-mqtt in /usr/local/lib/python2.7/dist-packag es (1.5.0)

Is the problem that's it's installed in python 2.7-folder? Sorry for the questions, I'm a real linux-layman

pdcemulator commented 4 years ago

@jockele79 Please install the Python3 packages as described here: https://github.com/Spanni26/pyHPSU/blob/ced0ddf6be407b23bc9213b43e06d2b880c951e1/README.md Do not use pip, use apt-get install packagename

@Spanni26 Please merge my PR with improved Readme, which already covers this

Spanni26 commented 4 years ago

Sorry, is merged now :)

Am 28.03.2020 um 09:25 schrieb pdcemulator:

@jockele79 https://github.com/jockele79 Please install the Python3 packages as described here: https://github.com/Spanni26/pyHPSU/blob/ced0ddf6be407b23bc9213b43e06d2b880c951e1/README.md

@Spanni26 https://github.com/Spanni26 Please merge my PR with improved Readme, which already covers this

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Spanni26/pyHPSU/issues/23#issuecomment-605413131, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2I5HDQKAZE4J3GF7TQSCTRJWYARANCNFSM4HYNINZQ.

Spanni26 commented 4 years ago

Yes, thats wrong :)

You need it for python3, not python2.

I would not install it via pip. Use apt or a similar tools (depending on your distribution)

Regards

Daniel

Am 28.03.2020 um 09:14 schrieb jockele79:

|pi@raspberrypi:~ $ sudo pip install paho-mqtt Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: paho-mqtt in /usr/local/lib/python2.7/dist-packag es (1.5.0) |

Is the problem that's it's installed in python 2.7-folder? Sorry for the questions, I'm a real linux-layman

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Spanni26/pyHPSU/issues/23#issuecomment-605412107, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2I5HDO2TF7IM7GQFFREY3RJWWXZANCNFSM4HYNINZQ.

jockele79 commented 4 years ago

ok, thanks, I tried this and receive the following output:

root@raspberrypi:/pyHPSU# pyHPSU.py -c t_hs -o mqtt Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in <module> main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 331, in read_can hpsu_plugin = module.export(hpsu=n_hpsu, logger=logger, config_file=conf_file) File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 77, in __init__ if self.username: AttributeError: 'export' object has no attribute 'username'

pdcemulator commented 4 years ago

Please post your config file (/etc/pyHPSU/pyhpsu.conf). It looks like that you do not have configured an username. It should look like this, modify to your setup.

[MQTT] BROKER = mybroker PORT = 1883 USERNAME = myuser PASSWORD = mysecretpass CLIENTNAME = rotex_hpsu PREFIX = rotex

jockele79 commented 4 years ago

here my config, I think this should work `

settings for pyHPSUd

[PYHPSUD] PYHPSUD_DEVICE=PYCAN PYHPSUD_LANG=EN PYHPSUD_PORT=/dev/ttyUSB0

settings for pyHPSU

[PYHPSU] PYHPSU_DEVICE = PYCAN PYHPSU_PORT = /dev/ttyS0 PYHPSU_LANG = DE OUTPUT_TYPE = MQTT

[MQTT]

BROKER = 192.168.178.10

PORT = 1883

USERNAME = edomi

PASSWORD = 123456

CLIENTNAME = rotex_hpsu

PREFIX = rotex

interval for each query for a value in seconds

values not listed here are not queried

[JOBS]

T_HS = 2 T_HS_SET = 25 water_pressure = 4 t_ext = 6 t_dhw = 25 t_dhw_set = 60 t_return = 4 flow_rate = 2 t_hc = 4 t_hc_set = 2`

pdcemulator commented 4 years ago

Remove the # sign before lines in MQTT section - currently they are commented out and were not used

jockele79 commented 4 years ago

the # was already deleted.
This morning I made a complete reinstallation of the raspi, everything was running correctly. During installation the apt-get install python3-paho-mqtt also was installed successfully. I can read the values manually, also the command -a is running, but after configuring MQTT within the config-file I get the following output:

pi@raspberrypi:/pyHPSU $ pyHPSU.py -c t_hs -d PYCAN -o MQTT Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in <module> main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 331, in read_can hpsu_plugin = module.export(hpsu=n_hpsu, logger=logger, config_file=conf_file) File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 77, in __init__ if self.username: AttributeError: 'export' object has no attribute 'username'

Find here the content of my actual config file:

`# settings for pyHPSUd [PYHPSUD] PYHPSUD_DEVICE=PYCAN PYHPSUD_LANG=EN PYHPSUD_PORT=/dev/ttyUSB0

settings for pyHPSU

[PYHPSU] PYHPSU_DEVICE = PYCAN PYHPSU_PORT = /dev/ttyS0 PYHPSU_LANG = DE OUTPUT_TYPE = MQTT

[CANPI] timeout=0.05

[MQTT] BROKER = 192.168.178.10 PORT = 1883 USERNAME = edomi PASSWORD = 123456 CLIENTNAME = rotex_hpsu PREFIX = rotex

interval for each query for a value in seconds

values not listed here are not queried

[JOBS] T_HS = 2 T_HS_SET = 25 water_pressure = 4 t_ext = 6 t_dhw = 25 t_dhw_set = 60 t_return = 4 flow_rate = 2 t_hc = 4 t_hc_set = 2`

Is there another config or adjustment I have to do?

Spanni26 commented 4 years ago

Changes mqtt.py a bit...

No Username is never emtpy. If the config can't be read, username is "None" and a messages is printed.

Please pull the lastest changes.

Am 29.03.2020 um 13:15 schrieb jockele79:

the # was already deleted. This morning I made a complete reinstallation of the raspi, everything was running correctly. During installation the apt-get install python3-paho-mqtt also was installed successfully. I can read the values manually, also the command -a is running, but after configuring MQTT within the config-file I get the following output:

|pi@raspberrypi:/pyHPSU $ pyHPSU.py -c t_hs -d PYCAN -o MQTT Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in

main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 331, in read_can hpsu_plugin = module.export(hpsu=n_hpsu, logger=logger, config_file=conf_file) File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 77, in __init__ if self.username: AttributeError: 'export' object has no attribute 'username' | Find here the content of my actual config file: `# settings for pyHPSUd [PYHPSUD] PYHPSUD_DEVICE=PYCAN PYHPSUD_LANG=EN PYHPSUD_PORT=/dev/ttyUSB0 settings for pyHPSU [PYHPSU] PYHPSU_DEVICE = PYCAN PYHPSU_PORT = /dev/ttyS0 PYHPSU_LANG = DE OUTPUT_TYPE = MQTT [CANPI] timeout=0.05 [MQTT] BROKER = 192.168.178.10 PORT = 1883 USERNAME = edomi PASSWORD = 123456 CLIENTNAME = rotex_hpsu PREFIX = rotex interval for each query for a value in seconds values not listed here are not queried [JOBS] T_HS = 2 T_HS_SET = 25 water_pressure = 4 t_ext = 6 t_dhw = 25 t_dhw_set = 60 t_return = 4 flow_rate = 2 t_hc = 4 t_hc_set = 2` Is there another config or adjustment I have to do? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or unsubscribe .
jockele79 commented 4 years ago

thanks a lot for your patience.

I pulled the latest changes, failure "username not set" appears, but username is definitely set inside config file. Do I need to insert it in another file?

Spanni26 commented 4 years ago

You run install.sh after download?

Am 29.03.2020 um 15:27 schrieb jockele79:

thanks a lot for your patience.

I pulled the latest changes, failure "username not set" appears, but username is definitely set inside config file. Do I need to insert it in another file?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Spanni26/pyHPSU/issues/23#issuecomment-605635457, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2I5HFDAV6KV52QNLFMSGDRJ5ECXANCNFSM4HYNINZQ.

jockele79 commented 4 years ago

yes, output changed a bit:

pi@raspberrypi:/pyHPSU $ pyHPSU.py -c t_hs -o MQTT Username not set!!!!! Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in <module> main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 332, in read_can hpsu_plugin.pushValues(vars=arrResponse) File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 92, in pushValues self.client.connect(self.brokerhost, port=self.brokerport) File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 839, in connect return self.reconnect() File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 962, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "/usr/lib/python3.7/socket.py", line 727, in create_connection raise err File "/usr/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

Spanni26 commented 4 years ago

Can I have a SSH access to that machine?

Please write me private dspannbauer at web.de

Am 29.03.2020 um 15:35 schrieb jockele79:

yes, output changed a bit:

|pi@raspberrypi:/pyHPSU $ pyHPSU.py -c t_hs -o MQTT Username not set!!!!! Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 332, in read_can hpsu_plugin.pushValues(vars=arrResponse) File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 92, in pushValues self.client.connect(self.brokerhost, port=self.brokerport) File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 839, in connect return self.reconnect() File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 962, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "/usr/lib/python3.7/socket.py", line 727, in create_connection raise err File "/usr/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused |

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Spanni26/pyHPSU/issues/23#issuecomment-605636547, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2I5HFN73SPIHF6LHCIW33RJ5FAVANCNFSM4HYNINZQ.

pdcemulator commented 4 years ago

run sudo pyHPSU.py -c t_hs ...

jockele79 commented 4 years ago

:-(, same result

pi@raspberrypi:/pyHPSU $ sudo pyHPSU.py -c th_hs -o MQTT Username not set!!!!! Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in <module> main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 332, in read_can hpsu_plugin.pushValues(vars=arrResponse) File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 92, in pushValues self.client.connect(self.brokerhost, port=self.brokerport) File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 839, in connect return self.reconnect() File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 962, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "/usr/lib/python3.7/socket.py", line 727, in create_connection raise err File "/usr/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

Spanni26 commented 4 years ago

Connection now is "refused" cause USERNAME is now "None".

Am 29.03.2020 um 15:55 schrieb jockele79:

:-(, same result

|pi@raspberrypi:/pyHPSU $ sudo pyHPSU.py -c th_hs -o MQTT Username not set!!!!! Traceback (most recent call last): File "/usr/bin/pyHPSU.py", line 335, in main(sys.argv[1:]) File "/usr/bin/pyHPSU.py", line 275, in main read_can(driver, logger, port, cmd, lg_code,verbose,output_type) File "/usr/bin/pyHPSU.py", line 332, in read_can hpsu_plugin.pushValues(vars=arrResponse) File "/usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py", line 92, in pushValues self.client.connect(self.brokerhost, port=self.brokerport) File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 839, in connect return self.reconnect() File "/usr/lib/python3/dist-packages/paho/mqtt/client.py", line 962, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "/usr/lib/python3.7/socket.py", line 727, in create_connection raise err File "/usr/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused |

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Spanni26/pyHPSU/issues/23#issuecomment-605639618, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2I5HGPGMX4FLOAZCWZOM3RJ5HMFANCNFSM4HYNINZQ.

jockele79 commented 4 years ago

this refers to the "Username" specified in MQTT-section in pyHPSU.conf?

Spanni26 commented 4 years ago

If no username is found by pyHPSU the Username is set to "None".

Am 29.03.2020 um 16:02 schrieb jockele79:

this refers to the "Username" specified in MQTT-section in pyHPSU.conf?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Spanni26/pyHPSU/issues/23#issuecomment-605640822, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2I5HB3HRCEPM37KUARIFDRJ5IHHANCNFSM4HYNINZQ.

pdcemulator commented 4 years ago

Did you setup config file in git clone folder or in /etc ?

try, here is the right place cat /etc/pyHPSU/pyhpsu.conf

Spanni26 commented 4 years ago

That was the problem. He edited the file in the source directory, noch in /etc/pyHPSU.

I showed him that per teamviewer.

Am 29.03.2020 um 16:08 schrieb pdcemulator:

Did you setup config file in git clone folder or in /etc ?

try, here is the right place cat /etc/pyHPSU/pyhpsu.conf

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Spanni26/pyHPSU/issues/23#issuecomment-605641781, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2I5HH7S7EYGGFQWXTADHLRJ5I4XANCNFSM4HYNINZQ.

jockele79 commented 4 years ago

problem was sitting in front of the PC, thanks a lot to you

pdcemulator commented 4 years ago

So clone this issue as it is resolved?

Spanni26 commented 4 years ago

Jup :)Am 31.03.2020 19:49 schrieb pdcemulator notifications@github.com: So clone this issue as it is resolved?

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.