jalmeroth / homie-python

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

Add/Change Subscriptions After Setup? #29

Closed airdrummingfool closed 7 years ago

airdrummingfool commented 7 years ago

There seems to be no way to add new subscriptions (using Homie.subscribe()) once the Homie object has been set up (with Homie.setup()). When I try, I get BaseException: ✖ subscribe(): has to be called before setup(). Is this a Homie convention rule, a design decision, or just a limitation of this library?

I wanted to use homie-python to model a Snapcast server's clients (which have settable volume, zone, etc) as Homie device nodes. However, snapcast clients can connect and disconnect from the server at will, and new clients can show up at any time. This doesn't seem to work inside the limitations of not being able to subscribe() to new nodes later in the lifecycle of my program.

jalmeroth commented 7 years ago

@airdrummingfool, thanks for your question and sorry for the delayed answer.

The current behaviour of subscribe() mimics, what homie-esp8266 is doing right now. It's not foreseen to dynamically subscribe to other topics that don't belong to your node nor to change those subscriptions during runtime.

airdrummingfool commented 7 years ago

Thanks for the reply and explanation!