TV Channel Favourites & IR Device buttons in Imperihome - How To

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.

Here is a screen shot of setting up the “Execute a HTTP request” in the Imperihome app, I couldn’t post that screen shot due to the 4 image limitation on the forum.

Bonus Feature - IR Device button command widgets

As I mentioned in the edit above, the Harmony plugin device for Vera has a HTTP request handler.

The attached screen shot of Imperihome is of widgets I created using that HTTP request handler, to send commands to my AVR. My AVR is a cheap one and has no ethernet port on it, so this is ideal for controlling IR devices, you could use this method to control any IR device that is a device on your Harmony Hub.

You need to know the DevceID of the IR device you want to control, in this example my AVR.

Again to list the device ID’s 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 AVR was listed and its DeviceID which is what you need:

Device : AV Receiver
Manufacturer : Denon
ID : 41309507
Model : avr-1513

To then list all the button commands of that device enter this command in to a browser.

http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=list_device_commands&cmdp1=41309507

ID:41309507 Being my Denon AVR amp.

It should list all the button commands available.

[code] Device : AV Receiver
ID : 41309507
Functions : [
Function : Power
Commands : [
Action : PowerOff
Name : PowerOff
Label : Power Off
,
Action : PowerOn
Name : PowerOn
Label : Power On
,
Action : PowerToggle
Name : PowerToggle
Label : Power Toggle

    , 
      Function :  NumericBasic
      Commands :  [ 
          Action :  0
          Name :  Number0
          Label :  0
        , 
          Action :  1
          Name :  Number1
          Label :  1
        , 
          Action :  2
          Name :  Number2
          Label :  2
        , 
          Action :  3
          Name :  Number3
          Label :  3
        , 
          Action :  4
          Name :  Number4
          Label :  4
        , 
          Action :  5
          Name :  Number5
          Label :  5
        , 
          Action :  6
          Name :  Number6
          Label :  6
        , 
          Action :  7
          Name :  Number7
          Label :  7
        , 
          Action :  8
          Name :  Number8
          Label :  8
        , 
          Action :  9
          Name :  Number9
          Label :  9
         
    , 
      Function :  Volume
      Commands :  [ 
          Action :  Mute
          Name :  Mute
          Label :  Mute
        , 
          Action :  VolumeDown
          Name :  VolumeDown
          Label :  Volume Down
        , 
          Action :  VolumeUp
          Name :  VolumeUp
          Label :  Volume Up
         
    , 
      Function :  NavigationBasic
      Commands :  [ 
          Action :  DirectionDown
          Name :  DirectionDown
          Label :  Direction Down
        , 
          Action :  DirectionLeft
          Name :  DirectionLeft
          Label :  Direction Left
        , 
          Action :  DirectionRight
          Name :  DirectionRight
          Label :  Direction Right
        , 
          Action :  DirectionUp
          Name :  DirectionUp
          Label :  Direction Up
        , 
          Action :  Select
          Name :  Select
          Label :  Select
         
    , 
      Function :  NavigationDVD
      Commands :  [ 
          Action :  Audio
          Name :  Audio
          Label :  Audio
        , 
          Action :  Back
          Name :  Back
          Label :  Back
         
    , 
      Function :  RadioTuner
      Commands :  [ 
          Action :  PresetPrev
          Name :  PrevPreset
          Label :  Prev Preset
        , 
          Action :  TuneDown
          Name :  ScanDown
          Label :  Scan Down
        , 
          Action :  TuneUp
          Name :  ScanUp
          Label :  Scan Up
        , 
          Action :  PresetNext
          Name :  NextPreset
          Label :  Next Preset
         
    , 
      Function :  Setup
      Commands :  [ 
          Action :  Setup
          Name :  Setup
          Label :  Setup
        , 
          Action :  Sleep
          Name :  Sleep
          Label :  Sleep
         
    , 
      Function :  NavigationExtended
      Commands :  [ 
          Action :  Info
          Name :  Info
          Label :  Info
         
    , 
      Function :  Miscellaneous
      Commands :  [ 
          Action :  AudioDelayDown
          Name :  AudioDelayDown
          Label :  AudioDelayDown
        , 
          Action :  AudioDelayUp
          Name :  AudioDelayUp
          Label :  AudioDelayUp
        , 
          Action :  ChLevel
          Name :  ChLevel
          Label :  ChLevel
        , 
          Action :  Dimmer
          Name :  Dimmer
          Label :  Dimmer
        , 
          Action :  DolbyAtmos
          Name :  DolbyAtmos
          Label :  DolbyAtmos
        , 
          Action :  DolbyPL
          Name :  DolbyPL
          Label :  DolbyPL
        , 
          Action :  DolbyPLIICinema
          Name :  DolbyPLIICinema
          Label :  DolbyPLIICinema
        , 
          Action :  DolbyPLIIMusic
          Name :  DolbyPLIIMusic
          Label :  DolbyPLIIMusic
        , 
          Action :  DSXOff
          Name :  DSXOff
          Label :  DSXOff
        , 
          Action :  DSXOn
          Name :  DSXOn
          Label :  DSXOn
        , 
          Action :  DSXSelect
          Name :  DSXSelect
          Label :  DSXSelect
        , 
          Action :  DSXWideHeightOn
          Name :  DSXWideHeightOn
          Label :  DSXWideHeightOn
        , 
          Action :  DSXWideOn
          Name :  DSXWideOn
          Label :  DSXWideOn
        , 
          Action :  DTSNEO : 6Cine
          Name :  DTSNEO : 6Cine
          Label :  DTSNEO : 6Cine
        , 
          Action :  DTSNEO : 6Music
          Name :  DTSNEO : 6Music
          Label :  DTSNEO : 6Music
        , 
          Action :  DTSNEO : XToggle
          Name :  DTSNEO : XToggle
          Label :  DTSNEO : XToggle
        , 
          Action :  DynEQ/VolOn/Off
          Name :  DynEQ/VolOn/Off
          Label :  DynEQ/VolOn/Off
        , 
          Action :  DYNEQ0db
          Name :  DYNEQ0db
          Label :  DYNEQ0db
        , 
          Action :  DYNEQ10db
          Name :  DYNEQ10db
          Label :  DYNEQ10db
        , 
          Action :  DYNEQ15db
          Name :  DYNEQ15db
          Label :  DYNEQ15db
        , 
          Action :  DYNEQ5db
          Name :  DYNEQ5db
          Label :  DYNEQ5db
        , 
          Action :  DynEQOn/Off
          Name :  DynEQOn/Off
          Label :  DynEQOn/Off
        , 
          Action :  DynVolDay
          Name :  DynVolDay
          Label :  DynVolDay
        , 
          Action :  DynVolEve
          Name :  DynVolEve
          Label :  DynVolEve
        , 
          Action :  DynVolMid
          Name :  DynVolMid
          Label :  DynVolMid
        , 
          Action :  DynVolOn/Off
          Name :  DynVolOn/Off
          Label :  DynVolOn/Off
        , 
          Action :  InputAux
          Name :  InputAux
          Label :  InputAux
        , 
          Action :  InputBluray
          Name :  InputBluray
          Label :  InputBluray
        , 
          Action :  InputCbl/Sat
          Name :  InputCbl/Sat
          Label :  InputCbl/Sat
        , 
          Action :  InputDvd
          Name :  InputDvd
          Label :  InputDvd
        , 
          Action :  InputGame
          Name :  InputGame
          Label :  InputGame
        , 
          Action :  InputTuner
          Name :  InputTuner
          Label :  InputTuner
        , 
          Action :  InputTvAudio
          Name :  InputTvAudio
          Label :  InputTvAudio
        , 
          Action :  Mode
          Name :  Mode
          Label :  Mode
        , 
          Action :  Mode5CH
          Name :  Mode5CH
          Label :  Mode5CH
        , 
          Action :  ModeDirect
          Name :  ModeDirect
          Label :  ModeDirect
        , 
          Action :  ModeDirect/Stereo
          Name :  ModeDirect/Stereo
          Label :  ModeDirect/Stereo
        , 
          Action :  ModeMultiCH
          Name :  ModeMultiCH
          Label :  ModeMultiCH
        , 
          Action :  ModeStandard
          Name :  ModeStandard
          Label :  ModeStandard
        , 
          Action :  ModeStereo
          Name :  ModeStereo
          Label :  ModeStereo
        , 
          Action :  Night
          Name :  Night
          Label :  Night
        , 
          Action :  PowerOff-All
          Name :  PowerOff-All
          Label :  PowerOff-All
        , 
          Action :  PowerOn-All
          Name :  PowerOn-All
          Label :  PowerOn-All
        , 
          Action :  QuickSelect1
          Name :  QuickSelect1
          Label :  QuickSelect1
        , 
          Action :  QuickSelect2
          Name :  QuickSelect2
          Label :  QuickSelect2
        , 
          Action :  QuickSelect3
          Name :  QuickSelect3
          Label :  QuickSelect3
        , 
          Action :  QuickSelect4
          Name :  QuickSelect4
          Label :  QuickSelect4
        , 
          Action :  Restorer
          Name :  Restorer
          Label :  Restorer
        , 
          Action :  Shift
          Name :  Shift
          Label :  Shift
        , 
          Action :  SpeakerA
          Name :  SpeakerA
          Label :  SpeakerA
        , 
          Action :  SpeakerA+B
          Name :  SpeakerA+B
          Label :  SpeakerA+B
        , 
          Action :  SpeakerB
          Name :  SpeakerB
          Label :  SpeakerB
        , 
          Action :  SurroundDown
          Name :  SurroundDown
          Label :  SurroundDown
        , 
          Action :  SurroundUp
          Name :  SurroundUp
          Label :  SurroundUp
        , 
          Action :  Tone
          Name :  Tone
          Label :  Tone
        , 
          Action :  TunerBand
          Name :  TunerBand
          Label :  TunerBand
        , 
          Action :  TunerMemory
          Name :  TunerMemory
          Label :  TunerMemory[/code]

Armed with this information you can start building some HTTP URL commands to control the device from Imperihome.

The standard URL command looks something like this:

http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=issue_device_command&cmdP1=41309507&cmdP2=Info&cmdP3=5

Where is says =Info you just change that part, for the command you want to send. So if you want to send a Volume Up command for example just change that part of the URL to =VolumeUp

Use the list generated of the available commands and their names to work this out.

Here are the URL’s I used to create my widgets in the Imperihome app.

Denon AVR:

Info

http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=issue_device_command&cmdP1=41309507&cmdP2=Info&cmdP3=5

VolumeUP

http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=issue_device_command&cmdP1=41309507&cmdP2=VolumeUp&cmdP3=5

VolumeDown

http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=issue_device_command&cmdP1=41309507&cmdP2=VolumeDown&cmdP3=5

Mute

http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=issue_device_command&cmdP1=41309507&cmdP2=Mute&cmdP3=5

ModeStereo

http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=issue_device_command&cmdP1=41309507&cmdP2=ModeStereo&cmdP3=5

MultiChannelStereo

http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=issue_device_command&cmdP1=41309507&cmdP2=Mode5CH&cmdP3=5

MultiChannel

http://192.168.1.100/port_3480/data_request?id=lr_Harmony184&cmd=issue_device_command&cmdP1=41309507&cmdP2=ModeMultiCH&cmdP3=5

So like with the TV channel favourites example, you just add new widgets on the Imperihome dashboard page, use the “Execute HTTP request” option and Post the URL etc. Add your icons and label text for each and you are good to go.

I really wish Imperihome would add proper support for Harmony devices in their app, but as of now this is the only way I have been able to add commands to control IR devices.

Excellent work! Wish I had the harmony but thanks for the write up.

Sent from my VS995 using Tapatalk

[quote=“tomtcom, post:4, topic:199437”]Excellent work! Wish I had the harmony but thanks for the write up.

Sent from my VS995 using Tapatalk[/quote]

Yeah shame you need a Harmony Hub, sure there are other ways and methods though.

If I don’t write these things up, I totally forget later how I did them LOL.

Lol, yes I have used this forum for my documentation as well…haha

Sent from my VS995 using Tapatalk