Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_on_enable takes 2 positional arguments but 3 were given #35

Open
AndreasL384 opened this issue Jul 30, 2023 · 4 comments
Open

_on_enable takes 2 positional arguments but 3 were given #35

AndreasL384 opened this issue Jul 30, 2023 · 4 comments

Comments

@AndreasL384
Copy link

Hi,

I installed your software today following the readme file.
When starting the truma_service, I get the following output:

andreas@raspberrypi:~ $ truma_service
2023-07-30 15:22:59,567 truma.main INFO started
2023-07-30 15:22:59,572 truma.main INFO Opening serial device /dev/serial0 in exclusive mode
2023-07-30 15:22:59,576 truma.main INFO Loop stats:
2023-07-30 15:22:59,577 truma.main INFO - Loop(_update_online_status) called 0 times, average duration 0.0s, load=0%
2023-07-30 15:22:59,577 truma.main INFO - Loop(send_status) called 0 times, average duration 0.0s, load=0%
2023-07-30 15:22:59,578 truma.main INFO - Loop(commit_updates) called 0 times, average duration 0.0s, load=0%
2023-07-30 15:22:59,579 truma.main INFO - Loop(send_update_status) called 0 times, average duration 0.0s, load=0%
2023-07-30 15:22:59,580 truma.main INFO - Loop(send_cp_plus_status) called 0 times, average duration 0.0s, load=0%
2023-07-30 15:22:59,612 truma.main INFO MQTT connected, client=<paho.mqtt.client.Client object at 0x76312520>, userdata=None, rc=0
2023-07-30 15:22:59,613 truma.main INFO Subscribing to ...
2023-07-30 15:22:59,617 truma.main INFO - service/truma/set/#
2023-07-30 15:22:59,618 truma.main INFO - service/truma/enabled
2023-07-30 15:22:59,838 truma.mqtt ERROR Caught exception in on_message: _on_enable() takes 2 positional arguments but 3 were given
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/andreas/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3591, in _thread_main
self.loop_forever(retry_first_connection=True)
File "/home/andreas/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
rc = self._loop(timeout)
File "/home/andreas/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1164, in _loop
rc = self.loop_read()
File "/home/andreas/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1556, in loop_read
rc = self._packet_read()
File "/home/andreas/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2439, in _packet_read
rc = self._packet_handle()
File "/home/andreas/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3033, in _packet_handle
return self._handle_publish()
File "/home/andreas/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3327, in _handle_publish
self._handle_on_message(message)
File "/home/andreas/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3570, in _handle_on_message
on_message(self, self._userdata, message)
File "/home/andreas/.local/lib/python3.9/site-packages/miqro/init.py", line 421, in _on_message
handler(self, payload)
TypeError: _on_enable() takes 2 positional arguments but 3 were given
2023-07-30 15:25:59,580 truma.main INFO Loop stats:
2023-07-30 15:25:59,581 truma.main INFO - Loop(_update_online_status) called 1 times, average duration 0.004874s, load=0%
2023-07-30 15:25:59,582 truma.main INFO - Loop(send_status) called 348 times, average duration 6.132758620689659e-05s, load=0%
2023-07-30 15:25:59,582 truma.main INFO - Loop(commit_updates) called 1521 times, average duration 3.68343195266273e-05s, load=0%
2023-07-30 15:25:59,583 truma.main INFO - Loop(send_update_status) called 1521 times, average duration 0.0001977172912557534s, load=0%
2023-07-30 15:25:59,583 truma.main INFO - Loop(send_cp_plus_status) called 1521 times, average duration 0.00010838724523339853s, load=0%

MQTT states are:
enabled (null)
online 1 [is set to 0 after some time]

I tried to uninstall and install again without success.
For me it seems to be a version conflict or something like that.

Can you suggest something?

Greets
Andreas

@pkoevesdi pkoevesdi mentioned this issue Jan 28, 2024
@pkoevesdi
Copy link

I have the same problem and I'll take a try to fix this.

@pkoevesdi
Copy link

pkoevesdi commented Jan 28, 2024

So, first quick test without understanding, what I do there: If I change the line 421 in miqro/__init__.py (in the path You find in your error message) from

handler(self, payload)

to

handler(payload)

The error message is gone.
Since I'm very early in trying / using this project, I cannot tell, if it works in general.
But I'd consider this error belonging to this project: https://github.com/danielfett/miqro/issues, only judged by the location of the errournous file.

@pkoevesdi
Copy link

pkoevesdi commented Jan 28, 2024

Proactively I also remove self, from line 417, because the function call is similar.
That didn't work, sending messages was broken.

With only changing line 421 as described above, everything seems to work.
Still, someone has to look after what I did. 😅

@AndreasL384
Copy link
Author

Hi @pkoevesdi,

I will give it a try in a few weeks, when installing it on my new raspi 4B with Venus OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants