Superb quality and spec AB-Com PULSe 4K SE. Crazy offer! Only £99! FREE UK DELIVERY! 4K UHD, Enigma 2, Multiboot 4 images & more!...
Superb quality and spec AB-Com PULSe 4K Rev II Twin Satellite tuner only £149! FREE UK DELIVERY! 4K UHD, Enigma 2, SATA HDD facility, Multiboot 4 images & more!...

Check if a channel can tune in with a bash script

FlexMcMurphy

Member
Joined
Sep 29, 2013
Messages
38
Reaction score
1
Points
8
Hello

I have a timer recording set up. Recently I realized it was recorded no new shows for weeks because the channel had changed frequencies and needed to be tuned in again. I was thinking of making a script, maybe using the openwebif api or something else, that could check if a channel can tune in then let me know if not.

And ideas much appreciated if there is a way to achieve this?

Cheers,

Flex
 
ABM won't remove dead channels. Nor will it update the timers. He can probably make a script to make a script to check if the service reference he has in his timers exists or not. There are sample custom mix files that also generate the service references.

Perhaps an easier solution is to adjust the auto timers?
 
I see your point abu, but my AutoTimers have survived all the recent moves in ITV and CH4 without any tweaking from me. Even my issue with ITV1 London HD (see my post in the ABM section just now) has not affected my AutoTimer for Coronation Street:D
 
Thanks both.

Yes, the issue was with one of the ITV channels that had to be tuned in again and when I did that I also had to set up a new Timer.

So I could try ABM and auto-timers then. But what is the other option about? How would I check if a service reference exists or not? I think the "zap" method in the OpenWebIf API does not return any helpful info if the Zap "fails". What are these "sample custom mix files that also generate the service references"? I think all I really want is a way to programmatically know if a given service reference can tune a channel in or not. Then I can put that in a script and have it send me an email if the Zap fails.

Cheers,

Flex
 
Thanks both.

Yes, the issue was with one of the ITV channels that had to be tuned in again and when I did that I also had to set up a new Timer.

So I could try ABM and auto-timers then. But what is the other option about? How would I check if a service reference exists or not? I think the "zap" method in the OpenWebIf API does not return any helpful info if the Zap "fails". What are these "sample custom mix files that also generate the service references"? I think all I really want is a way to programmatically know if a given service reference can tune a channel in or not. Then I can put that in a script and have it send me an email if the Zap fails.

Cheers,

Flex

@Flex and @abu - it turned out that I was just "lucky" that the Coronation Street autotimer happens to point at a still existing version of the ITV1 HD service! (lucky for me in that the boss would have been rather disappointed that her favourite soap hadn't recorded).

I'm not sure how you would programatically check for changed service references. Just maybe manually verify that timers are being set properly and are working? I'm sure @abu will be back with suggestions.
 
I see your point abu, but my AutoTimers have survived all the recent moves in ITV and CH4 without any tweaking from me.
Autotimers (and Timers) use the service id, so if that changes you'd need to reset them.
 
I'm not sure how you would programatically check for changed service references.
On reflexion I doubt that you can.

Not sure whether ABM can get the current service ids, rather than the ones stored in the lamedb file (which, at least for Freeview, is updated by a rescan).

For Freeview I just scrape their web-site every night and send myself an email if there are any changes.
 
The Freesat / Sky bouquet changes are reflected in a table updated daily on github and used by ABM. I can't locate the actual link right at the moment, but I'll check later.
 
Just to get back to my question...

My goal is to see if "a channel can be tuned in". Specifically, a channel that was working yesterday, does it still give me a picture today?

I had another look at the OpenWebIf API documentation and had a play with my enigma2 box.

I can get what I need using these methods: zap and tunersignal (or statusinfo).

I can zap the channel and then read the SNR values from the tuner...
http://192.168.1.104/api/zap?sRef=1:0:19:CBDD:831:2:11A0000:0:0:0:
then
http://192.168.1.104/api/tunersignal

When I zapped a channel that does tune in I get this back from "tunersignal":

Code:
{
 "agc": 97,
 "tunernumber": 2,
 "snr": 90,
 "ber": 0,
 "snr_db": "36.50",
 "tunertype": "DVB-T"
}

But I got these values when a service reference did not tune in a channel, snr=0

Code:
{
 "agc": 0,
 "tunernumber": 0,
 "snr": 0,
 "ber": 0,
 "snr_db": "0.00",
 "tunertype": "DVB-S"
}

I checked what would happen when I started up a recording and then zapped to a channel on a different transponder. "tunersignal" still only reported status for one tuner. I thought surely two tuners would have been in operation by then and I would get a status for both? I'll have to go with that looks like.

The "zap" method returns "true" whether a channel tunes in or not.
There is another method: "serviceplayable", you might think that would tell you if a channel can be tuned in but no. Maybe it simply checks if "this service reference exists in lamedb"? I don't really mind either way.

Cheers,

Flex
 
Just because you can tune to a channel, that does not mean it is broadcasting. Dead services are not removed from lamedb. They are only removed when you use the clear before scan option and only when the transponder is still listed in the xml file. If the transponder is no longer listed, it won't be probed and services wont be removed. ABM uses the data on the Si tables on the satellite to generate service list and bouquets. The ABM repository on github can be deleted, ABM will still work. The only effect would be update provider file function.

That being said, ABM will only read and generate what exists. If for arguments sake, you use one of these mix files, it will create a csv file for you.
https://www.world-of-satellite.com/...Hacks-Examples&p=391794&viewfull=1#post391794 You can then check if the service reference
in your timers exists in the csv file. If it does, it is an active service.

The norm is for channels to liven up on a new transponder in test mode. When those become the official channel, the old ones remain active for a few more days before they stop working. However, we have known channels to switch over instantly at 17:00.

You can also check the autobouquetswiki for channel changes. It is uploaded by @lraizer's box every morning. You can install it yourself and it will do the work on your box.

http://commando.org.uk/wiki/

https://github.com/LraiZer/AutoBouquetsWiki
 
Hi @abu baniaz
"Just because you can tune to a channel, that does not mean it is broadcasting."

But when I use the approach with the OpenWebIF API methods to "Zap" to a channel and then use "tunersignal" from my testing this does distinguish between a channel that can be-tuned in and a channel that can not be tuned-in. What I mean by that is: "The channel is broadcasting". snr and snr_db being ZERO is the give away that the channel is not broadcasting right?
Code:
{
 "agc": 0, 
 "tunernumber": 0, 
 "snr": 0, 
 "ber": 0, 
 "snr_db": "0.00", 
 "tunertype": "DVB-S"
}

These days channels are broadcasting 24/7 so if I get back snr and snr_db of zero then I would think that is a sufficient indication that I need to re-tune that channel.

Am I wrong about something here? Thank you for your suggested solution but it is a lot more effort to implement in a script than my quick and dirty but good enough (hopefully) idea.

Would appreciate any feedback if my idea is still flawed.

Cheers,

Flex
 
If you have an old lamedb (a few weeks), try tuning to Islam TV on 11641 MHz, Horizontal, 23000 2/3. I am pretty sure that you tune to a transponder and not a channel. If I am right, your approach will not work reliably. You will have signal, but no channel. Although the channel moved to 11225 MHz, Vertical, 23000 2/3, there are still services on the old transponder.

If your lamedb has been cleaned, here is one for you to test with.
 

Attachments

  • lamedb.zip
    lamedb.zip
    36 KB · Views: 1
  • Screenshot 2025-03-09 232534.webp
    Screenshot 2025-03-09 232534.webp
    18.1 KB · Views: 4
  • 1_0_1_1BC0_835_2_11A0000_0_0_0_20250309232638.webp
    1_0_1_1BC0_835_2_11A0000_0_0_0_20250309232638.webp
    22.7 KB · Views: 3
Last edited:
Thanks Abu,

In my enigma2 setup I have Islam TV with sRef=1:0:1:CB35:813:2:11A0000:0:0:0:

When I zap to that service reference:
http://192.168.1.104/api/zap?sRef=1:0:1:CB35:813:2:11A0000:0:0:0:

Code:
I get:
{
 "message": "Active service is now '1:0:1:CB35:813:2:11A0000:0:0:0:'", 
 "result": true
}

Then I check with...
http://192.168.1.104/api/tunersignal

And I get...
Code:
{
 "agc": 0, 
 "tunernumber": 0, 
 "snr": 0, 
 "ber": 0, 
 "snr_db": "0.00", 
 "tunertype": "DVB-S"
}

Or this...
IslamTV_sRef_SNR_Zero.webp

But when I stopped enigma2
# init 5
Then renamed my: /etc/enigma2/lamedb to /etc/enigma2/lamedb_old and then dropped your version in there and restarted my ZGemma.
# reboot

Now when I zap to that same sRef above but using your lamedb the screen is black but I get:
Code:
{
 "agc": 69, 
 "tunernumber": 0, 
 "snr": 78, 
 "ber": 0, 
 "snr_db": "15.50", 
 "tunertype": "DVB-S"
}

But I see that in your lamedb Islam TV has sRef=1:0:1:1BC0:835:2:11A0000:0:0:0:

When I zap to that sRef then check the SNR...
http://192.168.1.104/api/tunersignal

I get this...

Code:
{
 "agc": 76, 
 "tunernumber": 0, 
 "snr": 52, 
 "ber": 0,
 "snr_db": "10.50", 
 "tunertype": "DVB-S"
}

OK I see what you mean, in your lamedb IslamTV has a sRef that is not broadcasting a channel but has an SNR > 0.

But I'm still confused here.

This is my lamedb: View attachment lamedb.zip

The Islam TV in my lamedb [sRef=1:0:1:CB35:813:2:11A0000:0:0:0:] gives me a black screen and the SNR IS zero when I zap to it so in this case my little script logic should work fine right?

What is the difference between your lamedb and mine? Is mine older?

Maybe the risk is that if I later on do a fresh service scan (and maybe clear all services first?) but keep checking for a service on that old sRef then that sRef might have been allocated to some other services then my script would give a false positive?

Cheers,

Flex
 
My lamedb is older than yours. It has the old transponder details as well as the new one. So you have proved/seen your script won't work reliably.

Yes, the service references get reused. There is usually some time lapse though.
 
@abu baniaz
I have done some more testing with your lamedb file.
I opened your lamedb and then my lamedb in dreamboxEDIT to compare them.

In my lamedb I have one Islam TV with service reference:
1_0_1_CB35_813_2_11A0000_0_0_0_

In your lamedb there are two Islam TVs with service references:
1_0_1_CFA2_83A_2_11A0000_0_0_0
1_0_1_1BC0_835_2_11A0000_0_0_0

You said that your lamedb is older than mine. I'm not certain but I suspect mine is older than yours, so old that I don't even have the current (March 2025) sRef for Islam TV, probably the one I have is from years ago.

You suggested I check Islam TV on my box... I do that using the OpenWebIF API like this:
http://192.168.1.104/api/zap?sRef=1:0:1:CB35:813:2:11A0000:0:0:0:

When I do this I get SNR of 0 back from the "tunersignal" api method.

I get SNR = 0 because nothing is broadcasting on that sRef.

Can you try the same on your box? I was mistaken in my last post, trying that service reference with your lamedb was giving me a service with SNR > 0 but that's not because sRef=1:0:1:CB35:813:2:11A0000:0:0:0: has an SNR > 0 with your lamedb the reason is because the logic of the OpenWebIF "Zap" method just zaps to the first channel in the lamedb if that service reference doesn't exist, in your case a channel called: "(sub b +1000)", because in your lamedb sRef=1:0:1:CB35:813:2:11A0000:0:0:0: does not exist.

So where do I stand??

My rationale for this script is when I am recording a Monday to Friday TV series and I don't bother to check on those timer recordings for weeks on end. I don't want to find out suddenly that the last two weeks of recordings didn't work because the channel switched transponder. This happened to me recently!

Let's say a channel I am recording from every day changes service reference and I have a script that runs every day to check the SNR of that service reference. Surely the service reference my script is checking for will have SNR = 0 for a day or two after the channel I need finally leaves that sRef? Now maybe that's not for sure either, but in my experience with the ITV 2 + 1 changeover that happened last November I think it was... that sRef [ 1:0:1:27B5:805:2:11A0000:0:0:0: ] is still vacant! Likewise that Islam TV sRef in my lamedb is also still vacant after probably months also.

I accept your point that my script won't be guaranteed reliable. The reason is because if I try zaping to sRef=1:0:1:CB35:813:2:11A0000:0:0:0: maybe the channel I want no longer broadcasts on that sRef but there is no guarantee that another channel won't come along and be given that sRef, yes?

But I think my quick and dirty script might be good enough. Why? Because I would run it once a day, test the sRef of the channel I have a daily Timer for and then as soon as I get an SNR = 0 I can get it to send me an email. I doubt the old sRef will get re-used immediately by another channel or test service?

I think this approach would be enough to give me the kick to check if there is anything wrong with that channel and maybe google around to see if there are any plans to change that channels transponder then re-tune it if necessary and adjust my Timer. OK maybe I lost one day recording, but at least not weeks of them!

No doubt a better approach is to somehow find out what IS the latest service reference for the channel in my daily Timer and compare that sRef with the sRef in my Timer... but what you suggested way back in this thread to find the latest sRef seems like a lot more work. Ideally there would be an API to a web service with an up to date list of service references for all channels on Astra 28.2E and you could query by channel name. It would give you back the latest sRef or sRefs for that channel.

Anyway, thank you for your time.

Cheers,

Flex
 

OpenViX Feeds Status

Back
Top