Hi
I was messing about today and finally got some TV Channel favourites into the Imperihome app / Dashboard page.
Utilising the Logitech Harmony plugin for Vera and its HTTP request handler. So in the Harmony plugin device settings, first you need to turn on “Enable HTTP Request Handler” set this to Yes.
EDIT: Thinking about it, you may not actually need to enable this, as I am calling the Harmony plugin device via a luup.call_action. But I use the HTTP request handler for other things like adding commands in to Imperihome to control the AVR’s sound modes and volume. So its handy to have it turned on away. See below.
There are two ways you could go about doing this, either by creating a Vera scene for each TV channel or by using Logic Actions in PLEG.
I used PLEG as I didn’t want to create a load of new Vera scenes and clutter up my UI7.
I already had a PLEG device instance for “AV Devices” so I just added to this.
I created a new Condition for each TV Channel, see PLEG-Conditions-TV-Channels.png
For each Condition I left the expression blank / empty. But I needed to created the Conditions in order for the Logic Actions to appear which is the part we are interested in.
For each Logic Action we just need a bit of code to change the channel number.
Example for BBC News the code was:
luup.call_action("urn:rboer-com:serviceId:Harmony1", "IssueDeviceCommand",{DeviceID="41309505",Command="2",Duration="0"},184)
luup.call_action("urn:rboer-com:serviceId:Harmony1", "IssueDeviceCommand",{DeviceID="41309505",Command="3",Duration="0"},184)
luup.call_action("urn:rboer-com:serviceId:Harmony1", "IssueDeviceCommand",{DeviceID="41309505",Command="1",Duration="0"},184)
Example for Discovery Channel the code was:
luup.call_action("urn:rboer-com:serviceId:Harmony1", "IssueDeviceCommand",{DeviceID="41309505",Command="3",Duration="0"},184)
luup.call_action("urn:rboer-com:serviceId:Harmony1", "IssueDeviceCommand",{DeviceID="41309505",Command="2",Duration="0"},184)
luup.call_action("urn:rboer-com:serviceId:Harmony1", "IssueDeviceCommand",{DeviceID="41309505",Command="2",Duration="0"},184)
Each line of code sends a channel number e.g. 2 then 3 then 1. The device number 184 is my device number for my Logitech Harmony plugin device in Vera, so change that to whatever yours is. The DeviceID 41309505 is the device ID of my BT Youview STB in my lounge. You will need the DeviceID for your TV or your STB which ever controls the channel changes?
To find out what your DeviceID number should be enter this in to a browser.
http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=list_devices
Where the IP is the Vera IP and 184 is the device number of the Harmony plugin device in Vera, change these as required.
It should list all your AV devices on the Harmony hub, for example here is how my BT Youview STB was listed and its DeviceID which is what you need:
Device : YouView+
Manufacturer : Humax
ID : 41309505
Model : DTR-T2100
Repeat the process creating a Condition and then a Logic Action for each TV Channel favourite you want to add and just change the channel numbers in the code for each one etc. You need to Reload the LUA engine in Vera before they start working though.
Now in the Imperihome mobile app you need to create your dashboard widget to execute a HTTP request, this http command is sent to Vera via the local IP to run the desired PLEG logic action (or Vera scene) to change the channel etc.
The IP address is that of your Vera unit, the DeviceNum (191) is that of the PLEG device and the action name in this example “cBBCNews” is what I named the condition for the BBC news channel.
BBC News example:
http://192.168.1.100/port_3480/data_request?id=action&output_format=xml&DeviceNum=191&serviceId=urn:rts-services-com:serviceId:ProgramLogicC&action=RunAction&actionName=cBBCNews
Discovery Channel example:
http://192.168.1.100/port_3480/data_request?id=action&output_format=xml&DeviceNum=191&serviceId=urn:rts-services-com:serviceId:ProgramLogicC&action=RunAction&actionName=cDiscoveryChannel
So in the Imperihome app when you are creating your new widget for the TV channel you go to: Generic scroll down to “Execute a HTTP request”. Change the method from GET to POST and in the Local URL enter your change channel URL as in the examples above and click OK. I saved all my URL’s to a text file on my PC and then opened that on the phone, to more easily copy and paste the URLs etc, rather than typing them all out again.
The new widget is then created on your Imperihome dashboard page. Long press it and select Configuration. Then “Change Action Text” and type in the name of the TV channel the widget is for. Then long press it again and select “Change Icon” and select “Custom Image” from the bottom and for the “Default (state off) icon” click the Plus and then browse to your TV channel logo. Then click the back arrow.
Your widget will now have the channel logo and the text label will be that of the TV channel name. Press the widget and see if it works and changes the TV channel correctly? Repeat this process to create a widget in Imperihome for each channel.
If instead of using PLEG, you created a Vera scene for each TV channel containing the LUA code for that TV channel, then in the Imperihome app when setting up the “Execute a HTTP request” widget, you would have to use a URL like this, to run the Vera scene. Where SceneNum (86) is the number of the scene you want to run for that TV channel etc.
http://192.168.1.100/port_3480/data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=86
One obvious issue is I don’t have a URL for remote access to Vera via the MIOS relay server(s). It seems in UI5 it was fairly easy to create a single line HTTP command to send to Vera remotely when your phone is not connected to your local LAN. However in UI7 it doesn’t look as straight forward and I haven’t seen an easy way to do this yet.
So the channel changes would only work when the phone / Imperihome app is on the local WIFI. I don’t recommend you open up port 3480 on your firewall as a quick fix.