My first pass at this is now hosted on GitHub at https://github.com/calmor15014/HA-Component-mythtv-frontend
Forgot to add: working at this point is frontend status and title (if something is playing). Commands to frontends do not work in MythTV 0.28 and 0.29-pre due to an issue with the Services API. 0.27 is untested but should work. WOL is also not tested, and a variety of things could use added. Pull requests welcome!
Look like a great start (even with comments and a good README)!
I’ll try and make some time to test it out and let you know how it goes.
How about we use issues on your GitHub repo to keep track of tasks to do and problems encountered?
Thanks, and sounds good to me! The only thing I’ve been for less time than a HA forums user is a GitHub user, so as soon as I figure that out, I’ll give it a go.
As I mentioned, anyone is welcome to make suggestions or pull requests, including feature requests for both the front end and backend. I have a production MythTV 0.27+fixes and a VM running 0.28+fixes for testing. The production system doesn’t have all of the network config finished for testing HA though, which is why I can’t validate if the play/pause calls actually do anything. They don’t work in 0.28+fixes from what I can see, so may need to try to work around that.
Added a few. Thanks for the suggestion!
Great; this is fun!
I’m trying to figure out the state of play with the Python wrappers for the Services API.
The one you linked to (https://github.com/billmeek/MythTVServicesAPI) is only a few days old, but appears to be a refactoring of the module mentioned at https://www.mythtv.org/wiki/Python_API_Examples#The_module_used_in_the_examples_above
(e.g. pythonic_underscore names verses camelCase).
Do you know where this came from?
It would be nice to get an “official” or “best” one, and have it on PyPI for ease of HA using it.
The Python Bindings (https://www.mythtv.org/wiki/Python_Bindings) don’t seem to be what we want to use (Python 2 only), as far as I can tell.
Something else we could use for sharing the task is a GitHub Project. In your repo, find the “Projects” tab and start one. Then you could use that for tracking work and assigning tasks. It might be overkill, but it could also be good experience if you’re interested.
@lindsayward - the MythTVServicesAPI GitHub was posted at my request by the original author of the one on the MythTV Wiki, with some minor refactoring as you noticed. But, in my discussions with him, he’s not interested in having another active project to maintain, so he didn’t want to go through the effort to make sure it was totally compliant (PyLint, PyPI, or others?) so that it would be accepted to PyPI. Honestly, as even he says in the wiki page, this module isn’t necessary to interact with the Services API, but I wanted to use it as it both works and also fits HA’s best practices of using modules so that the greater Python community benefits.
If this works out well enough and it looks like there is enough support to get this component (and it’s future sibling for the backend) pulled into Home Assistant as a main supported component, then at that time I’d talk with him again to see if either he or I could do the work to get it into PyPI.
As for the Project, I’ll poke around there. I do enough project management at work (completely unrelated to software) so I’m familiar with the efforts associated. I’m not sure how that works in the open source software environment. I’d assume I’d need to ask for volunteers, otherwise I’m just setting all of the tasks to be owned by me (or you? ;))
My next task (personally) now that this is on GitHub and you can test it is to figure out my network setup so that I have a HA instance that can actually see the frontends I have and test out functionality with MythTV 0.27+fixes. Just have to do so when I have enough time to break the system.
By the way, the MythTV Python Bindings were used prior to the Services API and interacted directly with the backend / database. My preference is to use the Services API and let MythTV handle its database, even if that means a workaround for the SendAction and PlayVideo frontend services.
Thanks for the responses; that’s good to know.
I would be happy to put the Services API on PyPI if that was acceptable to the MythTV community. I went through the process for my Yeelight Sunflower library (for HA light platform): https://github.com/lindsaymarkward/python-yeelight-sunflower
If it’s just you and me making and using this platform then a GitHub Project is probably unnecessary, but it’s right there and easy enough to use. I think you’d add me as a collaborator so I can add myself to jobs. The main thing is to avoid duplication of effort (e.g. where we both work on the same bit without knowing the other is).
I ran the platform in a test HA instance running on my Mac, but with my real MythTV, last night. It works
I can see what media is playing and I can pause it. I found that play didn’t work though. If I start playing normally (my TV remote), then HA can pause it, but it can’t start it playing again. It sends a message, but nothing happens. Do you get the same thing or does yours play OK? I can look into it more tonight.
I haven’t had the chance to get an instance of HA running where it can talk to a working 0.27 frontend. It’s a long story, but I’m moving HA to an LXD container on my main server, and MythTV is on a VLAN that I haven’t been able to bridge over to the container without messing up PXE booting for the diskless frontends. Until I can get some time to break the networking on that server to solve the issue, I won’t be able to test on a real system. I’m hoping to do that this weekend.
Project is added, as it’s hard to say who may help out, and I like the idea of making sure we’re not duplicating efforts. You’re also now in as a contributor. Thanks for your contributions already!
By the way, which MythTV version are you running that the SendAction API function worked, and does PLAY work? I looked through the list of functions that my test 0.28+fixes VM reported as valid, and I didn’t see PLAY in that list, which is why I chose PLAYBACK.
PLEASE NOTE that the API installation method has changed and is now set up as a manual pip installation from github. If you installed the API prior to today, please check the README if you download the updated mythfrontend.py. Thanks!
I’m currently on
v0.28.1-21-ge26a33c according to
GetActionList shows a list of actions, which includes:
<Action> <Key>PAUSE</Key> <Value>Pause/Start playback</Value> </Action> <Action> <Key>PLAY</Key> <Value>Start playback</Value> </Action> <Action> <Key>PLAYALT</Key> <Value>Play selected item in alternate player</Value> </Action> <Action> <Key>PLAYBACK</Key> <Value>Play Program</Value> </Action>
Changing the action from
PLAY made it work for me. Perhaps PLAYBACK is to invoke playing from a menu item or something.
I wouldn’t worry about updating README and the like for breaking changes for now. (i.e. I’m sure the “if you installed prior to…” only applies to me :)) Let’s assume we’re the only ones using it and it’s in an unstable state, until release.
Thanks for adding me to the GitHub repo/project. I’ll keep doing updates via my fork+pull method for now, but add to the project - unless you suggest otherwise.
Interesting that your SendAction is working on 0.28. I’ll have to get the version on my VM test system because it decidedly doesn’t work.
I think the way we are working is good, gives me some experience with having to manage the PRs. You’re welcome to self-assign yourself to issues though, unless you really want me to do the assigning.
By the way, I was able to get my network bridges set up correctly without destroying everything else in my system, and migrated over to an LXC/LXD container this weekend.
I was able to test out WOL, SendAction, the new installation method (auto-installing mythtv_services_api) and your new title text - all worked out great. I could play/pause from Home Assistant’s web interface normally. I also have 0.28 running on my production system (and the same base install, Ubuntu 16.04 server w/ added-on mythtv packages) so I’m not sure why my VM doesn’t work right. I closed the open issue without action, and hope this week to start working on some more of the code, including the notify component, which shouldn’t be that painful. Because I want to use “mythfrontend” as the platform name in the
configuration.yaml, I’m assuming the best course of action is to put two folders in GitHub, one called media_player and one called notify, and then both can have a
Zoneminder, for example, does it this way, with a
zoneminder.py being in both the sensor and camera folders within site-packages, but different files for the different functions.
I’m happy with the multiple folders plan since the end result will just be a single file submitted to the main HA repo for each platform.
Agree, I think things are progressing fairly well. I haven’t has as much time to work on it as I’d liked, but I think that’s the bane of every open source project. The benefit is in multiple people contributing. This is actually the first time I’ve contributed any code (albeit very, very little original code).
Are you developing right on a test machine/VM or are you copying code around? I’m still trying to get my workflows set up; made more difficult by the fact that I use two or three different machines of all major OS flavors (OS X, Windows 7, Linux), and that my dev server and production servers are containers on another machine altogether.
My actual Home Assistant runs on a Raspberry Pi 3 on top of my fridge.
For this and other dev, I’m running HA right on my Mac, using a virtualenv, as described at: https://home-assistant.io/developers/development_environment/
I’ve had this component on my TODO list for a long time (see the post you replied to), so yes, it’s good to have multiple people.
I’m in Australia, by the way
I am interested test this, but how to install the services API?
This is what I get when starting with Custom Component enabled
ImportError: No module named 'mythtv_services_api'
We recently made a change to the component and the automatic installation of the mythtv_services_api is not included anymore. I’ll update the readme to add installation instructions for that tomorrow.
Sorry for the inconvenience!
@lindsayward - sounds like a good way to work. I should stick to developing on one machine, but I move around too much to do that it seems.
My main and main development HA systems are now in LXD containers on my main server, which because my wife is quite tolerant, is an honest HP blade server. MythTV backend and a number of other things run on there as well.
What part of Australia? I visited Sydney last year, beautiful city. Unfortunately I didn’t get far outside of the city. I’m just outside of Pittsburgh, about 600km west New York City.