calmor15014/HA-Component-mythtv-frontend

Connect to REST API natively

Closed this issue · 9 comments

Remove the requirement to pull the mythtv_services_api and communicate natively with the MythTV frontend's REST API. This should be a relatively simple change, but should be a major step toward automatic integration setup as requested in issue #39.

Will use the mythtv_services_api code as reference to access the API natively.

Sounds like a great idea, and indeed a way forward.
Let me know if you want to distribute the work. I'm just getting back into doing HA dev (updated my light platform today).

@lindsaymarkward - thanks, I'll let you know. I think I'm going to tackle one of the older issues first to pull the configuration into a platform. That could help with localizing the calls to the API, and regardless of the number of frontend or backend entity types we add, we can keep the API calls in one place. Then it's in one place and fits in with the HA design philosophy.

Trying to learn how that works from a few other integrations like Zoneminder and rpi_gpio, since the HA developer documentation example is extremely basic and rather lacking in how it actually functions. Some of the examples use DOMAIN and others ignore it completely, importing the component in each entity somehow.

@lindsaymarkward ...except that HA specifically says it wants that stuff in separate, PyPI-installable chunks, and the tutorial they link to for publishing stuff on PyPI is, eh, overwhelming to say the least and probably why Bill wasn't interested in doing it. Not sure where to move from here on this one.

After a couple days of digging, it looks like Zoneminder specifically created a PyPI project to abstract the library connection even further. Honestly, considering how clean it allows their code to be, I think that's probably the real way to go here, if someone wants to take on basically taking Bill's work and making it into something Home Assistant can use more natively. Maybe a team effort can get this done.

Going to close this one for now and open another with more information.

I have published a library (for HA interaction with yeelightsunflower) to PyPi before, so I'll take this on. I offered this to Bill but they didn't want to at the time. We'll effectively fork it and have to keep an eye out for updates.

@lindsaymarkward Thanks a ton! I actually opened a new project for that here because I think it's going to require some effort and multiple steps on both the fork and here. Let me know how you prefer to handle the API repository.

I saw that. I don't think we need a project for it. I'll just copy the code, test it as a local library then publish to PyPI. I've only done it once before, but if you do local testing you can get it all sorted before committing to it.
I'm aiming to do it this weekend.

I'm all for that if you want to port over. I appreciate all the effort to do that. From never having done it before, it looks a little daunting.

I do think the optimal end state for the PyPI library does look more like the Zoneminder version, where the API actually creates objects which HA or others can easily consume... which means sizeable changes to this code too. For now though, I'd be happy with just being able to import it automatically.

Let me know if I can buy you a beverage for your effort.

OK, so testing locally, it's very easy to install the existing package (after downloading it) via
pip3 install -e mythservicesapi

I think this means the repo is already in good shape to become a PyPI package.
I asked Bill about uploading to PyPI: https://forum.mythtv.org/viewtopic.php?f=33&t=3039&p=18588#p18588
I'm not sure if there are things that should be fixed, or if this would become an unofficial fork or if they'll let me know when changes are made and I'll maintain PyPI...
but at the least we'll be able to do it... Ideally, I would like to get the endorsement first.