RJ / heatmiser-neohub.py

Python library to talk the direct-lan-api to control a Heatmiser Neohub / Neostats - and home-assistant component
34 stars 15 forks source link

Simple "read" neoplug status #6

Open JohnRaynor opened 5 years ago

JohnRaynor commented 5 years ago

I know this is a pretty elementary question, but I really struggle understanding "async" programming. What do I do to just read status of a Neoplug device ("Greenhouse") from a calling program? I have my program switching the neoplug on and off fine, I just cant work out the syntax to read the status.

Sorry to waste your time with a fairly simple question.

mibarkway commented 4 years ago

Did you get anywhere with this..? I have just done a similar thing, starting with a similar level of python knowledge... My solution is very hacky, but I do now have some code that does what I need.

Basically, I started with the "neo-cli" library, popped in my hub's IP and port numbers, and hard coded it to run the "list" command, which came out with a beautiful list of all my zones, with temps, so good start.

Then I knife-and-forked the code a bit to take out the functions I wasn't using and change things round a bit so the one command I use became an (async) function call, that was mostly fine, with lots of small changes and re-runs...

Then I added a wrapper function which is done with a regular 'def'. This calls all the async stuff and contains the 'loop', an instance of the neo class and the 'run_until_complete' thing which spits out the usable output which is returned into the normal python world.

If you want it to run multiple times, then cut out the loop.close bit, or it wont run again, otherwise you should end up with a callable function that works like regular code gives you some useful info about your neo system...

Hope that helps..!

Michael

alexreid42 commented 1 year ago

I encountered the same issue, my inelegant solution is attached. .177 is the address of the Neohub, rename the two txt files to .py.

image

Alex

extract.txt master.txt