jerrod-lankford / GarageQTPi

An MQTT server for a raspberry pi garage door opener. Most commonly used as a HomeAssistant cover component.
MIT License
75 stars 36 forks source link

struct.error: cannot convert argument to integer #17

Closed WalterWampe closed 6 years ago

WalterWampe commented 6 years ago

Hi there, I am quite frustrated atm and don't know what I am doing wrong... This is what I get when I try python main.py:

Welcome to GarageBerryPi! Traceback (most recent call last): File "main.py", line 50, in client.connect(host, port, 60) File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 768, in connect return self.reconnect() File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 940, in reconnect return self._send_connect(self._keepalive, self._clean_session) File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2125, in _send_connect keepalive)) struct.error: cannot convert argument to integer

Can you tell me what my problem is? Thank you!!

WalterWampe commented 6 years ago

my config:

mqtt: host: smartassi port: 1883 user: garage password: wampe availability_topic: "garagepi/out/availability" doors:

    id: 'garage'
    relay: 17
    state: 21
    state_topic: "garagepi/out/state"
    command_topic: "garagepi/in/set"
    camera_topic: "garagepi/out/pictureStream"
    image_File_path: "home/pi/motion/snapshot.jpg"
jerrod-lankford commented 6 years ago

Can you go to line 43 in main.py and change port = CONFIG['mqtt']['port'] to port = int(CONFIG['mqtt']['port'])

I dont know why this would be necessary but its the only thing i can think of. If that fixes it ill update main.py

DanielNL commented 6 years ago

Hey Jerrkawz,

I have the exact same errors when i try to start main.py. I can see you already closed the problem, so i hope the solution is found?

The only difference in my config.yaml is that by host i have the ip addres of my home assistant embeded mqtt broker set, might this be causing the error?

Kind regards,

Daniel

Ps. I only just started to test out home assistant this week so i have a long way to go, be gentle :)

EDIT:

Ok, i got 1 garage door to move finally. I did a complete fresh install of everything and then it still wouldn't work, updated to paho_mqtt 1.3 and then got the struct error again so reverted back to 1.2

Still not working though, so i tried running the garage.py file in the lib folder at some point and saw an error saying: File "garage.py", line 3, in from lib.eventhook import EventHook ImportError: No module named lib.eventhook

I copied over the content of this file to garage.py and commented out the import on line 3 and the door started moving when i manually started main.py!

Now that i've got it working i edited the import in garage.py from lib.eventhook to eventhook seeing as that its in the same folder. Seems to do the trick, although i am curious as to why the statement is there or my garage.py file is stored in the lib folder. Seems one of the 2 is wrong..

Kind regards,

Daniel

jerrod-lankford commented 6 years ago

I closed the issue because I never got a response from @WalterWampe. The lib.EventHook import seems wrong, it should just be EventHook since they are in the same dir. I can update. As for the paho mqtt issue I did post a potential solution above, i just have never tested it, If you want to you do what I suggested and see if that fixes the error.

DanielNL commented 6 years ago

Hey Jerrod,

thanks for the response. At the start of the problem i did try your suggestion to define it to an integer, no difference however.

Seeing as the pi i was installing this on was already running stable for 3 years the requirements file didn't work for me either, something to do with http vs https. I installed both instances manually, albeit version 1.3.

When using the latest version (1.3) on a completly new rpi image i got the same error again, so i switched back to 1.2 with seemed to fix that specific error.

Now not being familiar with decent scripting i tried running the garage file manually and the rest of my findings is in my latest eddit.

As of this afternoon i've got both doors running perfect within HA, wich was my goal before i was willing to migrate from my old solution.

So all in all another experience had, thanks for taking the time to put this all together. Higly appreciated!

Regards,

Daniel

Op za 19 mei 2018 22:37 schreef Jerrod Lankford notifications@github.com:

I closed the issue because I never got a response from @WalterWampe https://github.com/WalterWampe. The lib.EventHook import seems wrong, it should just be EventHook since they are in the same dir. I can update. As for the paho mqtt issue I did post a potential solution above, i just have never tested it, If you want to you do what I suggested and see if that fixes the error.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Jerrkawz/GarageQTPi/issues/17#issuecomment-390431121, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhwZORse9IS2iYSsKEMPv2Wqi953QIcks5t0IKfgaJpZM4SFTSG .

jerrod-lankford commented 6 years ago

Glad you got it working. I commited the lib.eventHook to eventHook change and the int() change, event though it doesnt seem to help. Ill file an issue to figure out why it doesnt work with 1.3. Thanks!

nielsenaa commented 3 years ago

Hi guys, The bug has something to do with setting (believe it or not) a particular protocol (MQTTv31 or MQTTv311) - check it out i don't need a specific protocol version (and im not good enough in python right now) , but if it can help anyone else who would have the time to go through client.py for fixing the bug.. here you go, i narrowed it down to that by trial and error