Adding MythTV Frontend component

Tags: #<Tag:0x00007fd0778896f0>


It might have to be part of the official distro, which is also why I want to get it approved. I’m not even sure how to go about doing that.

Right now the major limiting factor is that the MythTVServiceAPI code is still in a state of flux and not in PyPI, so if I hard-code a version to pull in, it could break, and therefore won’t work. I could copy the relevant parts of the code into the frontend component itself, but that goes against the “modular” design philosophy that hass wants to use. That, and I like the idea of having the API being able to be updated separately for new versions of MythTV in the future.

I’m still running 0.27 or 0.28 (can’t even remember now) so having a 29.0 tester is a good thing. I’m also not running anything (even hass) on a Pi, so it’s probably good to have a tester working on the hardware that’s more common.

@lindsayward has done all of the fun stuff like the video images. Sadly, I don’t even use the component yet. I have a whole house MythTV system, but just use the frontends on the TV to control everything. I’ve been too busy playing with servers and getting Z-Wave and automations set up to really get into the media_player components. That and my Samsung TVs don’t seem to play nicely with HA anyway, so I can’t just say “watch TV” and have the TV turn on, which takes a lot out of the magic - I still need the remote… at least until I build some IR blasters. Once I do get into HADashboard again, I’ll probably get back to using the component.


I delved into the mythtv services api and I see what you mean. I’m still trying to work out what I can do with the api that will help with my automation ideas and for voice commands via HA or Google Assistant.
BTW. My samsung TV also does not play so nice with HA. I use a chromecast connected to the TV so I can control it with HA or google assistant (inc. google home). Alternatively, I could control the TV from my RPi frontend by CEC, but I haven’t set that up yet. You could dedicate a PiZero to that job if it helps. Then you can also control inputs, etc.


I’ve spoken with the developer of MythTVServicesAPI a few times. Great guy, very helpful, but like the rest of is, is working on this as a hobby and skill improvement.

You can check that Frontend Services link that I sent as well as the DVR service or Videos service pages to get an idea of what you can do via the API. I think it’s possible to search for a program, even if we have to pull the list of programs and search within HA.

I just bought a few NodeMCU chips from Amazon for $7.50 (a little more than a PiZero but has WiFi built-in) that I could use; I had them slated to run wired sensors. Realistically, maybe I should just use the PCs running the frontends that already have IR receivers and wired IR outputs… though that requires the PC to be on before TV control is possible. I like that idea!


Hi @glenn20 and thanks for freshening up this thread :slight_smile:

I do now use the component in its present state, on my main HA (no longer just dev), and it’s mostly going fine (some errors in logs, but nothing broken). I can use Siri (via homebridge) to start/stop MythTV playing.

I love the idea of saying something like “Hey Siri/Google, play the oldest episode of Community” or something, but that might be a bit much to ask.


Hey @lindsayward! Been a while!

What kind of errors are you seeing? Just curious.

Also, how are you doing the homebridge integration on the hardware side? I had homebridge working, but don’t have the Apple TV or spare iPad to sit at home. I found I moved things into groups on my phone, but all that work disappeared after a reboot.

That does sound like a good use case for the show search. Not sure we could get to being able to say oldest, but that might be a default option (oldest unwatched)?


I do have an Apple TV for remote Siri-homebridge, but I think it worked fine inside my house/network before I had that.

Here’s an excerpt from my logs recently (with nothing playing at the time). The Thread-2 warning entries are my/our own, which are then repeated by HA:

WARNING (Thread-2) [custom_components.media_player.mythfrontend] Error with 'MythTV' at htpc.local:6547 - Connection problem/Keyboard Interrupt, URL=http://htpc.local:6547/Frontend/GetStatus
INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: timestamp=1519214221.8485281, exception=, level=WARNING, message=Error with 'MythTV' at htpc.local:6547 - Connection problem/Keyboard Interrupt, URL=http://htpc.local:6547/Frontend/GetStatus, source=custom_components/media_player/>
WARNING (Thread-2) [custom_components.media_player.mythfrontend] {'state': 'idle', 'menutheme': 'default', 'currentlocation': 'mainmenu'}
INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: timestamp=1519214221.9037533, exception=, level=WARNING, message={'state': 'idle', 'menutheme': 'default', 'currentlocation': 'mainmenu'}, source=custom_components/media_player/>
INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: new_state=<state media_player.mythtv=off; supported_features=20529, friendly_name=MythTV @ 2018-02-21T21:57:01.932726+10:00>, entity_id=media_player.mythtv, old_state=<state media_player.mythtv=idle; is_volume_muted=False, media_duration=0, volume_level=0.0, supported_features=20529, media_position=0, friendly_name=MythTV @ 2018-02-21T21:45:41.037900+10:00>>


I had been running the plugin in my production environment also, at least until I removed all media_player components. I also found an occasional connection error. It would seem that could be a timeout error, if MythTV doesn’t respond fast enough. From the MythTVServicesAPI code:

    if self.postdata:
        response =, data=self.postdata,
        response = self.session.get(url, timeout=self.opts['timeout'])
except exceptions:
    raise RuntimeError('Connection problem/Keyboard Interrupt, URL={}'

We have the timeout coded pretty low (1s if I remember right) because local network access should be fast. But, if your MythTV server or network, or even HA server are under some stress at the moment of request, it might trip this error. Perhaps we could set up a config option to increase it?


Good. I’m happy to add timeout as a config option… I went to do it but the master and dev branches are a bit disjointed now (dev is is 2 commits ahead, 3 commits behind master) and I can’t quite tell what it should be.
Do you want to update this so that dev and master are both the latest, then I’ll checkout dev and add the next update to it?


I’ll do that today so that we’re ready to go!


I started to look at it this weekend, but my Git knowledge is pretty bad… I’ll try to focus on getting them straightened out early this week.


Okay, I think I fixed it. Dev now shows 0 behind, 1 ahead (which just seems to be the merge request to get the master branch updates in). I also removed the novalidate option from the API requests, as the 0.27 version issue was fixed in MythTVServicesAPI.

I’m still pretty green with GitHub, so if I need to do something else, feel free to let me know what that is or if you have other input there, let me know.

Beyond that, I think it’s ready to go?


@calmor15014, @lindsayward, judging by the timestamps, you’re as busy as I am,
probably more.

I just looked at the source and noticed that the ‘old’ method of detecting errors
is still in use. Starting with 0.1.3, use exceptions like this:

    except RuntimeWarning as warning:    
        print('\nWarning: "{}"'.format(warning))                                
    except RuntimeError as error:                                               
        sys.exit('\nFatal error: "{}"'.format(error))


As to SendAction, the fix for 0.28 (and above) was committed
in Aug. 2017


Starting with MythTV version 30.0, the Services API module is included
with the Python Bindings. Import it like this:

from MythTV.services_api import send

This will no longer be maintained on the previous github account. See:

Services API


Thanks. I noticed after upgrading to HA 0.88 that this component no longer works, so I’ll look into doing an update that fixes it and also refers to the Python bindings instead of the deprecated API.


Yes - I just encountered this too. Following advice here and here I hacked a fix for myself on hassio:

cd /config/custom_components
mkdir ./mythfrontend/
cp ./media_player/ ./mythfrontend/
touch ./mythfrontend/
rm ./media_player/

In mythfrontend/, change:

from homeassistant.components.media_player import (


from homeassistant.components.media_player import (
    MediaPlayerDevice, PLATFORM_SCHEMA)
from homeassistant.components.media_player.const import (

You may also need to reinstall the mythtv_services_api as hassio 0.88 also seems to have bumped to python 3.7 and I needed to reinstall.



Hi @apiguy Bill :slight_smile:

I asked on the MythTV forum… but can you tell me how to install the API from this new location (on a machine without MythTV)?
Thanks :+1:


Could I ask anyone using this component to test my latest update?

@calmor15014 - if it works for you, you could merge the PR into master. EDIT: merged and link updated.

I have chosen to change mythfrontend to mythtv and I’ve also included the notify platform, which was previously in another branch and has been updated.
I’ll update the code to use the new API/location when I can find out how :slight_smile:


I’ve updated the readme and installation instructions.
It would be great if someone could give this a go and let me know if there are any areas that need improvement. Thanks.


I just updated my hass-dev environment to 0.89.2 and am still working out some of the config. I intend to finally upgrade my production environment soon, so I’ll be making a push to get everything sorted out here as well. I’ll merge and test by this weekend. Still on MythTV 0.27 though; that’s going to have to wait until after hockey season to upgrade…