jalmeroth / homie-python

A Python-implementation of the homie v2 convention.
https://github.com/marvinroger/homie
54 stars 15 forks source link

Looping speed #45

Closed psyciknz closed 5 years ago

psyciknz commented 5 years ago

In the arduino version of homie, it calls homie.loop to go to sleep.

Here in homie.python, we're using time.sleep(#).

I currently have mine set a 1 as per examples, but for a fan control script, what would happen if this was much higher? The homie.loop includes looping, sleep and keeping a mqttc client awake for callbacks.

bodiroga commented 5 years ago

Hi @psyciknz!

I don't know if @jalmeroth will add something more later, but here is my answer:

homie-python spans a thread for the mqtt connection and the callbacks, so you don't have to worry about sleeping too much time. As Arduino is not able to execute more than one thread, its library needs the homie.loop() function to be called to ensure that the underground tasks are being executed, but here we don't have that problem. Things are a little bit easier in a multiprocess environment :wink:

Enjoy the library and if you have any suggestion or improvement, don't hesitate to open a new issue.

Best regards,

Aitor

jalmeroth commented 5 years ago

Thanks for your explanation, @bodiroga! 👍