jalmeroth / homie-python

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

[WIP] Homie v3.0.0 #47

Open bodiroga opened 5 years ago

bodiroga commented 5 years ago

Hi @jalmeroth!

This PR is a WIP to update the library to the latest Homie version: 3.0.0. https://github.com/homieiot/convention

Even if it is WIP, I have updated all the example files to the new API and in my preliminary test everything works fine :+1: But I would like to know for opinion about the new class names and functions. Don't hesitate to suggest or criticize whatever you want :stuck_out_tongue_closed_eyes:

Best regards,

Aitor

jalmeroth commented 5 years ago

Hi Aitor,

wow impressive work, once again! Have you seen my efforts in dev from 8 months ago? It might makes more sense to merge your changes here.

Let me know what you think.

Best regards, Jan

bodiroga commented 5 years ago

Hi Jan (@jalmeroth)!

Sorry, but I'm not sure if I have understood what you mean. Do you want me to make my changes against your dev branch? I don't know if that's going to be easy 😞 Anyway, we should talk about how to handle this situation: what Homie version should we support in the library? Homie v2? Homie v3? Both at the same time? What's the best way to deal it? Two repositories and two libraries (homie-python and homie3-python)? Everything in the same repository? What about the "pip" installation process? How can that be managed?

I think that I will wait until we decide something about this before changing anything in the PR 😉

Best regards!

Aitor

bodiroga commented 5 years ago

Hi @jalmeroth!

I have made a new commit to update the library to Homie 3.0.1 (they have introduced a new "$retained" attribute to the properties to make them stateless) and have added two new examples.

Let me know how do you want to address the different versions of the library (Homie 2 and Homie 3) and looking forward to seeing the library marked as stable :wink:

Best regards

Aitor

esdeboer commented 5 years ago

Hi @bodiroga,

Shouldn't the isValidFormat check in helper.py check for none for everything except enum and color, as the format is not required for the other datatypes? (or is it because of my old python 3.4 on my pi that I get a WARNING:homie.property:'None' is not a valid format for float)

Regards, Eric

stefanroellin commented 5 years ago

I have tested the branch and have found the following issues:

  1. in the 3.0 specification "$online" is not used anymore, however there are still updates to this topic. Should probably be replaced with "$state".
  2. during startup there is a warning that the deviceId is invalid, (since it is set to "None" in __init__)
  3. personally I am not interested in the "signal" topic. Hence a possibility to exclude it would be good.

Thanks for your work!

rafdaems commented 5 years ago

Thank you very much for this fork. My openhab installations seems to autodetect mqtt subscribers created by your framework.

One question: I don't understand the implementation of "settable". see: https://homieiot.github.io/specification/ under 6.4.1 properties.

pls advise ?

ababilone commented 5 years ago

Hi there,

Any news on this subject ? I'm also working on an OpenHAB 2.4 integration and this 3.0 binding is just what It needs. The work done by @bodiroga looks awesome.

Do you plan to merge it someday ?

Thanks for any feedback!

bodiroga commented 5 years ago

Hi guys!

Shouldn't the isValidFormat check in helper.py check for none for everything except enum and color, as the format is not required for the other datatypes?

Fixed @esdeboer!

  1. in the 3.0 specification "$online" is not used anymore, however there are still updates to this topic. Should probably be replaced with "$state".

Fixed @stefanroellin!

  1. during startup there is a warning that the deviceId is invalid, (since it is set to "None" in init)

Fixed!

  1. personally I am not interested in the "signal" topic. Hence a possibility to exclude it would be good.

Yeah, you are right, but as Homie 4 is going to completely remove the "stats" information, I'm going to keep it for now. It doesn't cause any harm and someone can find it useful :wink:

pls advise ?

Hi @rafdaems! Could you please be more specific? I need to know first what is what you don't understand? :+1:

Please, test the new changes and report if you find any error! Thanks for you help! :+1:

Best regards,

Aitor

esdeboer commented 5 years ago

Thanks for the fixes Aitor, looks good. I don't get the deviceId warning anymore and I can add properties with a datatype without format.

Kixunil commented 5 years ago

Hi, thanks a lot for this code! I used it for solight-homie and it works with OpenHAB. It's very nice how easily I could create a plugin for OpenHAB using this code.

stedon81 commented 5 years ago

Hi, I experienced some hang up issues with this homie implementation in this branch. Is it possible, that this library is not thread-safe? From my code, it looks like different threads would block each other if they try to do update or read operations at the same time. Regards, stedon81

stedon81 commented 5 years ago

OK, I found the answer - it's not homie, but the underlying paho mqtt library which is not thread safe: https://github.com/eclipse/paho.mqtt.java/issues/453#issuecomment-402092568 Nevermind, sorry to have bothered :-)

mjcumming commented 5 years ago

I have put together a python library for Homie 3 that I would like some feedback on. You can get it here

https://pypi.org/project/Homie3/

Mike

yozik04 commented 5 years ago

I think this pull request needs to land to a separate repo and produce a separate pip package.