Just getting started with questions

Hey, just getting started with openhab and trying to get my head wrapped around programming again after several years away from it. Anyway have a project in mind but am having a hard time finding good documentation or examples on certain elements. At this point just trying to get a bit of an example framework put together to show a friend what it will do for controlling his video switching at a sports grill.

Right now he is mainly DirecTV tuners on seperate TVs and 2 projectors, which is all well and good till he found out that DTV doesn’t have PAC12 network. The system worked fine running the DTV app for changing channels on each TV. Now to get PAC12 he got service with the local cable company that carries it, and the only way to get that channel on the system is a hacked together diplex a single cable channel on the same coax as DTV, then tune the TV to chan 3. Which is not simple for waitresses to figure out.

So I’m planning on putting a matrix switcher in that will give a little more functionality and allow expansion in the future. Controlling the matrix switcher through serial seems pretty straight forward, and the DTV tuners have a well documented IP command structure. But I’m having issue with getting my interface together how I want.

What I would like to do is have a frame/group with a separate selection item for each DTV tuner that has a dropdown with the most used channels programmed in. Got that figured out, but then I want another frame/group that has each TV in the system with a dropdown to select what tuner to display on it, except I want the mappings to dynamically update with what channel each tuner is set on, for example right now I have:

Selection item=tuner_1 label=“DTV Tuner 1” icon=television mappings=[0=“CBS Sports”, 1=“FOX Sports1”, …etc]
Selection item=tuner_2 label=“DTV Tuner 2” icon=television mappings=[0=“CBS Sports”, 1=“FOX Sports1”, …etc]

which works great, I have a rule set up to send the command to change channel when a new station is selected, no problem. But what I can’t figure out is how to take the text of the current selected mapping for tuner_1 through tuner_8 and populate the mappings for the TVs so you don’t have to go back to a different screen and see what tuner is on what station. for example…

Selection item=Bar_TV1 label=“Bar TV 1” mappings=[tuner_1.text???, tuner_2, tuner_3…]

this is where I’m lost. What am I missing?

Also it would be nice to build an array for the channel to station name mapping to make it easier for adding/changing channels in the future

Thanks in advance


I’m not at my computer right now so I can only provide pointers.

First of all, you can create a channels.map file and put it in the configurations/transform folder and you can reference the mappings file in you sitemap definition instead of manually listing the mappings as you are doing here.

I’m not sure I understand exactly what you are asking for the other part. Perhaps a screenshot of what you have with some arrows for where you want to go would help.

But a couple pieces of advice:

  • it is very difficult to combine two items on the same line in the sitemap. For the most part you have to create a third item which gets updated by a rule to contain the merged
  • you cannot change the label of an item from the rules, only the value.

The solution to your problem may be, though less elegant, to just duplicate the information you want on both frames.

This is the screen that will have the tuners, the selection is just a list of the commonly used station names that when selected will send the TCP command to change to that channel on that tuner.

On another screen I plan on having the TVs listed with a selection on each one to pick which tuner for the matrix switch to select. Instead of the selection box text being populated with “tuner 1” “tuner 2”… I want to populate with the mapped station that each tuner is tuned into, eg. What you see currently selected in the first picture. So it should look like this…

But the contents of the selection on the TVs will change depending on what station the tuner is on.

Thanks for the help

As far as I have been able to tell you can’t get there from here very easily. First of all, it doesn’t appear that you can reference a .map file for your mappings entries so you will have to repeat them for every Item. :frowning:

Similarly you cannot dynamically change a Selection. However, you can modify the label I think to include the value.


Number Bar1 "Bar 1 [MAP(channels.map) : %s]" ...


Selection item="Bar1" mappings="...

If you create channels.map and populate it with your number to name mappings you use for the Selection the name of the channel will be appended to the label so it will look something like:

Bar 1          ESPN2  MLB Network v

Bummer. Thanks for the help though. It just seems like it should be doable, but from what I can see the selection element is a bit limited in what it can do. I’ll have to think about it a little more and maybe figure out a workaround

It might be worth while looking into a third party tool for the UI and using the REST API. That seems to be a common approach. https://community.openhab.org/t/alternative-uis-openremote-irule-iviewer/1839/6 thread might point you in some useful directions.

I know this thread is a little old but a comment here relates to something I am doing or trying to do. I have a ‘Selection’ item defined in my Sitemap file and I want to use a .map file to define the selection options. This can then be used by multiple controls. Can you please advise what the control defintion would be in the sitemap file to force use of the .map file rather than a list defined in the sitemap file itself. My best guesses didn’t work and Google let me down!

Thank you

You can’t. The selection on the sitemap only supports “mappings” as defined here. This is not the same as a .map file.

Aha - that explains why it didn’t work!

Thanks for the info.

Maddyn - I know this is a very old thread but curious what you came up with for a solution. I’m more interested in how you are controlling DirecTV through openHAB. I have searched all through the forums and this is the closest I have even seen to anyone even trying to control DirecTV… Maybe others are already doing it and there just aren’t any topics on it… If anyone has a working example, I’d love to see how you are going about it…