I want to be able to listen for the MythTV backend. If mythbackend is running, then I want it to indicate it as “Running.” For some reason, my backend crashed when watching live TV in Kodi and when the signal drops out, Kodi seems to hang and after about a minute, when I try to watch other channels, I get “no channels available” in Kodi regardless of any channels leading me to check if backend is running, but then I did not know that it had crashed, so I went ahead and restarted it. So I thought to myself “why not let me know if the backend stopped running” which I came here to ask if it’s possible to do process monitoring. My backend is started using systemd.
So my question is, is it possible to monitor the process?
PS: I’m sure you guys might be curious about why my MythTV backend crashed in an event of a poor signal from a television tower, but that’s not what I came here to ask, isn’t it? Well, I do get poor signals from time to time… Whenever that happens, I could have Home Assistant notify me via espeak TTS that “MythTV backend is stopped” once I can figure out how to monitor the process.
I wonder if there was some sensor in Glances that you could watch to see if MythTV was running. There’s support for Glances and you could make template sensor to automate notification, but I don’t have any experience or knowledge of MythTV to be able to give anymore advice than that.
Okay. I did not see a “Glances” component in the Sensors section.
And you don’t have to have experience with MythTV. If a process is stopped, I want Home Assistant to know that and display it in the frontend. Maybe something as simple as pidof mythbackend. If pidof does not output PID number, meaning a process isn’t running, then Home Assistant will say “Stopped” next to “MythTV Backend.” as a sensor.
I looked through there that you’ve provided and there isn’t a way to get the specific information about the process that’s running in the system out of either running, total, thread, and sleeping.
I did some more digging and found this page for API Documentation and that’s about it. I did not look through the topics in the right but will do some more digging later.
But I suppose I can make use of a RESTful sensor if I could find how I can get a specific process info regarding it’s running state.
Well, I might give command_line sensor a try. but I’m wondering what is the polling interval for queuing a value of an output? Maybe I should not have started my thread…
Edit: Okay. I have implemented the MythTV Backend sensor:
- platform: command_line
command: if pgrep "mythbackend" > /dev/null; then echo "Running"; else echo "Stopped"; fi
name: "MythTV Backend"
But it seems to me when I am looking at the front end of HA to see if I’ve started and stopped my MythTV backend, it seems to take about about two minutes. With no way of adjusting the polling interval, I’m expecting something to be more of “instant” – maybe about 2 second interval. Is that going to cause too much of a burden to the CPU just to query a running process?
I am thinking of creating a media player platform for MythTV and wanted to see if any other HA users would be interested… Anyone?
I would like to be able to have scenes that set it to the recordings screen, and have a “pause” in actions (like a “movie break” scene where the lights come on and the movie is paused…), as well as being able to see what’s playing and control it a bit from the HA UI (for fun). Can anyone else think of use cases for it?
I don’t use MythTV but I can’t see any downside in you contributing. And maybe that’s all it takes to start getting other users like me interested in using it.
I think your project outline sounds good; these are things that most would be interested in.
Re-reviving an old thread, but wanted to mention that adding native notification support for MythFrontend would be another use. Right now I have a REST notification hitting the Frontend/SendMessage API endpoint. I’m not using it for anything yet, but have it setup.
I’m interrested also in an frontend component.
I could use it for automation purposes.
For example: if the frontend is playing something dim the lights, if it paused or stopped, stop dimming the lights.
Even something more advanced what I would like:
Use in house location to play the content on 1 frontend, after moving to another room, continue the content on the room.
Or a least, make a bookmark, and be able to start the other frontend from the bookmark.
This is what I use - platform: command_line name: "Myth backend status" command: systemctl show mythtv-backend | awk -F= '/^SubState=/ {print $2}' scan_interval: 60
@yelt_be, I am only using it for status in the UI for right now, I haven’t hooked it up to any automation. I need to setup an IR blaster or something to be able to turn the TV off since I don’t have HDMI-CEC ability from my frontend.
The mythfrontend network control port was originally created for exactly the type of presence-based automation that you are describing and is currently used by Linux MCE for that purpose.
I’m actually working on a media_player component for mythfrontend using the MythTV API Services (requires MythTV 0.27 or later), so I’m curious how many people would be interested in both frontend media_player components and backend sensor or other type of components, and what features might be requested. I’m new to Home Assistant, but have been running MythTV for at least 10 years. My goal for the mythfrontend component is to use wake-on-LAN to turn the system on via scene, raise the lights when playback is paused, and the standard controls that media_player components have like play/pause, track forward/back, and volume control.
I already have a sample working on my demo setup that can identify if the system is on, idle, playing, and paused, and if it is either playing or paused, it shows the title of the program. One challenge I found in demo testing was that 0.28+fixes in the Ubuntu repositories (16.04) did not respond to SendAction and PlayVideo API events. 0.27+fixes (which I’m running on my production system) does seem to work normally. So, my sample doesn’t allow you to operate the frontend in those cases. One idea is to use SendKey events instead of SendAction, but if a user re-configures the MythTV keymaps, it may require extra complexity in the component and will require more configuration in HA’s YAML to make sure actions are sending the right keys.
Any comments / feedback appreciated. If there’s enough support, I can build it out enough to release. I’d be especially interested in any input as to what others want in a backend component, since most of the API is related to recordings / scheduling. A sensor to call out whether it’s running would be simple to access by checking for a valid response from the API.
Hi @calmor15014 - I’m keen. How about we move this discussion to the #development category?
I would be happy to work with you on the media_player platform. It’s on my TODO list, so if you’re doing one, we could combine forces. Perhaps you could invite me to a GitHub repo?
Moving the discussion to #development is probably a good idea. I’m quite new here though so I’ll defer to you on how to do that?
I don’t have it on GitHub yet, and I’m not sure if I can just yet either. In accordance the Home Assistant best practices information, I’m using the Python file on the MythTV API Services wiki instead of writing my own Python device interface code. The issue is that I don’t own that file, and am still talking with its creator about options for hosting it somewhere that HA can pull it automatically (probably GitHub vs. pip)
For now I could probably start a GitHub on what I have and explain how to set it up for testing and development purposes in part of the docs?