Remote for Settopbox with Neutrino GUI (Tuxbox)

Tags: #<Tag:0x00007f187624c2b0> #<Tag:0x00007f187624c1e8> #<Tag:0x00007f187624c120>

Hi OpenHabers,

here i would present you my little project to build a remote for my Settopbox (Satreceiver).
I use here a Coolstream Tank Settopbox. Its running with a Linux OS from the Tuxbox Project.
And the GUI is Neutrino.
https://wiki.tuxbox-neutrino.org/wiki/Kategorie:Hardware
The OS contains also a Webserver “nhttp” with a API
https://wiki.tuxbox-neutrino.org/wiki/Neutrino#Der_Web-Server_.28nhttpd.29

With the exec and the http binding
on OpenHab you will able to receive and send commands to the Reciever.

Here my coolstream.items:

String Coolstream { http=">[*:POST:http://192.168.2.116/control/rcem?%2$s]" } // receive the string from the sitemap for remote
String Sender "[%s]" {channel="exec:command:getsender:output"} // receive the Station String from the script
String Sendung "[%s]" {channel="exec:command:getinfo:output"} // receive the Programm Sting from the script

Here my exec.things:

Thing exec:command:getsender [command="/etc/openhab2/scripts/./getsender.sh", interval=15, timeout=5] //script call
Thing exec:command:getinfo   [command="/etc/openhab2/scripts/./getinfo.sh", interval=15, timeout=5] // script call

If you send this to the box:

http://192.168.2.116/control/getchannel?format=json&epg=true

You will receive a json answer like that:

{"success": "true", "data":{"channel": [{"id": "c4c404530001445d",
"short_id": "4530001445d",
"epg_id": "c4c404530001445d",
"short_epg_id": "4530001445d",
"name": "ProSieben",
"logo": "/share/tuxbox/neutrino/icons/logo/4530001445d.png"
,"isActiveChannel": "true"
,"firstEPG": {"eventid": "311592804660650875",
"description": "Thor",
"info1": "Thor\nAction, USA 2011\nAltersfreigabe: ab 6",
"info2": "Donnergott Chris Hemsworth wird seiner göttlichen Kräfte beraubt! Gerade noch sollte Thor 
seinem Vater Odin auf den Thron von Asgard folgen, da wird er als Strafe für seine Unbeherrschtheit 
auf die Erde verbannt. Ohne göttliche Allmacht und ohne seinen magischen Hammer Mjolnir fällt es 
dem Helden schwer, sich dort zurechtzufinden. Doch dann nehmen sich die Astrophysikerin Jane 
Foster und ihr Team seiner an. Kurz darauf wird das Militär auf den kampfstarken Hünen 
aufmerksam.\n\nRegie: Kenneth Branagh\nDrehbuch: J. Michael Straczynski, Mark 
Protosevich\nKomponist: Patrick Doyle\nKamera: Haris Zambarloukos\nSchnitt: Paul 
Rubell\n\nDarsteller:\nChris Hemsworth (Thor)\nNatalie Portman (Jane Foster)\nAnthony Hopkins 
(Odin)\nTom Hiddleston (Loki)\nStellan Skarsgård (Erik Selvig)\nKat Dennings (Darcy Lewis)\nClark 
 Gregg (Agent Coulson)\nColm Feore (King Laufey)\nIdris Elba (Heimdall)",
 "startTime": "10:43",
 "timeTotal": "130",
 "timeElapsed": "91",
"percentage": "70"
  }
,    "secondEPG": {"eventid": "311592804660650876",
"description": "Marvel Short: Black Widow & Hulk",
"info1": "Marvel Short: Black Widow & Hulk\nAnimation, USA 2017",
"info2": "Black Widow und Hulk finden eine tickende Zeitbombe. Werden die beide eine verheerende 
Explosion verhindern können?",
"startTime": "12:53",
"timeTotal": "1"
}
}
]
}}

To get from the box the current station and program, i used two scripts and the exec binding.

First, two scripts that get me the channel “name” and the “description” part from the Json request:
These scripts are stored in /etc/openhab2/scripts/ and must be made executable via the console with the command “sudo chmod 755”.

getsender.sh:

#!/bin/bash
curl -s 'http://<yourboxip>/control/getchannel?format=json&epg=true' |perl -ne 'print "$1" if /name": "([^"]+)"/'

getinfo.sh:

#!/bin/bash
curl -s 'http://<yourboxip>/control/getchannel?format=json&epg=true' |perl -ne 'print "$1\n" if /description": "([^"]+)"/g' |head -1

And here the part from my sitemap:

    Text      label="Sender"           item=Sender        icon="none"
    Text      label="Sendung"          item=Sendung       icon="none"
        Switch                             item=Coolstream mappings=[KEY_POWER="POWER",KEY_MUTE="MUTE"]
        Switch                             item=Coolstream mappings=[KEY_EXIT="EXIT",KEY_HOME="HOME",KEY_OK="OK",KEY_EPG="EPG"]
        Switch                             item=Coolstream mappings=[KEY_INFO="INFO",KEY_UP="UP",KEY_DOWN="DOWN"]
        Switch                             item=Coolstream mappings=[KEY_LEFT="LEFT",KEY_RIGHT="RIGHT"]
        Switch                             item=Coolstream mappings=[KEY_RED="RED",KEY_GREEN="GREEN",KEY_YELLOW="YELLOW",KEY_BLUE="BLUE"]
        Switch                             item=Coolstream mappings=[KEY_PLAY="PLAY",KEY_PAUSE="PAUSE",KEY_RECORD="RECORD",KEY_STOP="STOP"]

I looks in the sitemap like that:

Have fun with it.

BR Peter

Could you post a link to your project rether than a generic landing page, thanks

And here if you want how to add the channel list and “zapp” with selection in the sitemap:

item:

String Programme { http=">[*:POST:http://<box ip>/control/zapto?%2$s]" } // zapto is the call for the receiver to zapp

“zapto” is Neutrino unique. Other can differ.

and this is for the sitemap:

Selection label="Senderliste"      item=Programme  mappings=[<sender id>="DMAX",<sender id>="n-TV",<sender id>="WELT",<sender id>="N24 DOKU"]

“sender id” is the placeholder for the sender id, mostly a digit. That can be read out of the bouquet

Have fun.