AMikeM
Posts: 8
Joined: Sun Jan 04, 2015 11:40 am

Using RPi to power off/on PVRs

Tue Jun 04, 2019 12:45 pm

Hi –

I have a couple of PVRs recording TV shows. They’re pretty reliable, but occasionally they will lock up, and TV shows fail to get recorded. Over the years I’ve learned that nothing will bring them back to life except a manual switch-off/switch-on. So I’ve written a script (that runs as cron job on an RPi 3) which pings the PVRs regularly and warns me if either of them is down, so that I can reset it – but obviously I can’t do that when I’m away from home.

So I’d like the Rpi to control the AC power to the PVRs, so that if the script detects a locked-up PVR, it can automatically turn the AC power off and on again, to force a reboot. I’d rather not have any wireless elements, nor anything requiring an internet connection (very flaky broadband in my isolated rural area). I’m confident I can handle any programming involved, and I’m a reasonably competent electrician - many decades living in old houses! - but I have only limited electronics experience.

Has anyone done a similar project?

PhatFil
Posts: 1672
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Using RPi to power off/on PVRs

Tue Jun 04, 2019 1:45 pm

While i dont control PVRs i do use wifi smart switches with a community developed firmware which can be flashed OTA without any h.w intervention.
https://github.com/arendst/Sonoff-Tasmota/wiki

select a smart switch based on TUYA h/w the give away being the use of a bundled phone app called 'Smart Life' or in some cases Brandname-life for an OTA reprogramming using the tuya-convert method as detailed
https://www.youtube.com/watch?v=O5GYh470m5k&t=333s

I use some of these devices which aslo output power usage metrics
https://www.amazon.co.uk/gp/product/B07 ... UTF8&psc=1


with the Tasmota firmware installed you have a number of options, most users host a mqtt broker (on the pi) and use mqtt to send commands to and query metrics from the smart switch. Though you can use http commands too.. And if wanted you can develop rules to apply on the switch to have it act independently.
http://www.steves-internet-guide.com/py ... subscribe/

AMikeM
Posts: 8
Joined: Sun Jan 04, 2015 11:40 am

Re: Using RPi to power off/on PVRs

Tue Jun 04, 2019 2:51 pm

@ PhatFil: Many thanks for the comprehensive reply! I went to all the links you provided - and watched the (very good) YouTube video - and I if I understand it correctly, I would end up with a smart socket that is controlled via WiFi, and I would use mqtt commands issued by the RPi to control the socket. I'll look into mqtt (as I don't know anything about it) and see what that would involve.

However, I had hoped to avoid any wireless technology if possible - I want to keep everything hard-wired. I'm really looking for a hardware solution involving (I guess) the RPi controlling via GPIO pins, a latching relay which switches an AC socket.

simonmsh
Posts: 11
Joined: Sat Jun 01, 2019 6:07 pm

Re: Using RPi to power off/on PVRs

Tue Jun 04, 2019 5:37 pm

Apologies for not answering the question, but have you considered fitting a TV Hat to your Pi and running TVHeadEnd? I have, and it's the most reliable and feature-rich PVR I've ever used.

AMikeM
Posts: 8
Joined: Sun Jan 04, 2015 11:40 am

Re: Using RPi to power off/on PVRs

Tue Jun 04, 2019 6:49 pm

@ Simonmsh: The TV Hat certainly looks interesting. What EPG and interface software do you use?

PhatFil
Posts: 1672
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Using RPi to power off/on PVRs

Tue Jun 04, 2019 9:01 pm

probably more pi/relay wisdom to be found in posts here that you can access with a simple search than anywhere else.

just be mindful mains ac can kill and take every care.

AMikeM
Posts: 8
Joined: Sun Jan 04, 2015 11:40 am

Re: Using RPi to power off/on PVRs

Tue Jun 04, 2019 10:07 pm

@PhatPhil - Yes, I've been working my way through a lot of posts - and of course, I fully respect mains AC - I re-wired my first house in 1979! Thanks again for your input.

simonmsh
Posts: 11
Joined: Sat Jun 01, 2019 6:07 pm

Re: Using RPi to power off/on PVRs

Wed Jun 05, 2019 4:56 am

AMikeM wrote:
Tue Jun 04, 2019 6:49 pm
@ Simonmsh: The TV Hat certainly looks interesting. What EPG and interface software do you use?
I just use TVHeadEnd running on Raspian, which I think is the most common configuration. By default TVHeadEnd uses the standard EPG transmitted with Digital Terrestrial TV, although it can be configured to use other EPGs.

AMikeM
Posts: 8
Joined: Sun Jan 04, 2015 11:40 am

Re: Using RPi to power off/on PVRs

Sat Jun 08, 2019 9:27 am

@PhatPhil - following your suggestion I bought a smart power strip (Innens XS-A25) which I have successfully flashed with the Tasmota firmware, so now I just have to learn about mqtt brokers and clients... an interesting journey I hope... thanks again.

PhatFil
Posts: 1672
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Using RPi to power off/on PVRs

Sun Jun 09, 2019 12:06 am

AMikeM wrote:
Sat Jun 08, 2019 9:27 am
@PhatPhil - following your suggestion I bought a smart power strip (Innens XS-A25) which I have successfully flashed with the Tasmota firmware, so now I just have to learn about mqtt brokers and clients... an interesting journey I hope... thanks again.
fwiw i found node-red a fantastic tool for automating responses to all sorts of triggers or stimuli (input from all sorts of sensors)

as for mqtt, just install the broker (appy security if you wish, i didnt bother my lighting control commands are far from sensitive..) point your devices at the broker ip and its just gonna work for you.. this is a good reference for mqtt http://www.steves-internet-guide.com/py ... subscribe/

AMikeM
Posts: 8
Joined: Sun Jan 04, 2015 11:40 am

Re: Using RPi to power off/on PVRs

Mon Jun 10, 2019 12:39 pm

@PhatFil (with apologies for misspelling your name previously!) :

Success so far!

After getting the mqtt broker running on the Rpi, and happily sending messages to and from the device, I still couldn't get the device to respond to mqtt commands. However, I found a user-defined template for the XS-A25 on the Tasmota github page, which worked perfectly. So now, thanks to your suggestions, I can now control each socket on a power strip from the command line on the Rpi. Now I just have to incorporate the appropriate commands into my cron script and I'm home and dry.

This home automation stuff is fun, isn't it? I owe you a beer!

PhatFil
Posts: 1672
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Using RPi to power off/on PVRs

Mon Jun 10, 2019 3:16 pm

go for it.. you may also want to check out tasmoadmin https://github.com/reloxx13/TasmoAdmin if your start collecting more tasmota devices..

there is the google group sonoffusers https://groups.google.com/forum/#!forum/sonoffusers
for support if you hit tasmota snags..

Return to “Automation, sensing and robotics”