Control TiVo box over telnet

Could I ask you if you have got an Amazon dot and if you have set up custom skills?

Also who is your ISP? as mine is Virgin Media and I cannot forward internal ports to external ports.

Virgin is my isp… No custom skill either, just the emulated hue component fur hone assistant.

So I have finally managed to connect my tivo box to my network and I have run the commands from terminal on my mac using the ip address of my tivo box but it doesnt seem to like it. Here is what I did:

IRCODE STANDBY | telnet 192.168.0.18 31339

and it spits out:

Trying 192.168.0.18…
Connected to 192.168.0.18.
Escape character is ‘^]’.
Connection closed by foreign host.

Any idea on this? Did you have similar issues to mine?

Right so…

From command line on my mac if I say "telnet 192.168.0.18 31339” It logs me into the session and then if I say “SETCH 144” it changes the channel to 144 but it doesnt like: echo “SETCH 144| telnet 192.168.0.18 31339”

Try adding as a switch… I dud come across that error too. Think it should work in a switch.

Try that and let me know how you get on.
. You’re very close rho!

I have gone straight to HA added the following in my configuraton.yaml:

platform: command_line
  switches:
    youview_on:
      command_on: 'echo IRCODE STANDBY | telnet 192.168.0.18 31339'
      command_off: 'echo IRCODE STANDBY | telnet 192.168.0.18 31339'
      friendly_name: Virgin On

but get errors:

    17-03-18 16:05:22 ERROR (Thread-1) [homeassistant.util.yaml] while parsing a block collection
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 61, column 3
expected <block end>, but found '?'
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 182, column 3
17-03-18 16:05:22 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block collection
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 61, column 3
expected <block end>, but found '?'
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 182, column 3

Any idea where am I going wrong?

Thanks.

Yamls well temperamental.
Looks like you need an extra space on the command on.

You’ve prob got a space somewhere…

Whsts happening on these lines?
182 - assume this is the switch?
61

I have set my MQTTs as a switch and therefore I have to put the command line switch as:

  - platform: command_line
    switches:
    youview_on:
    command_on: 'echo IRCODE STANDBY | telnet 192.168.0.18 31339'
    command_off: 'echo IRCODE STANDBY | telnet 192.168.0.18 31339'
    friendly_name: Virgin On

but now I get an error saying:

ERROR (MainThread) [homeassistant.config] Invalid config for [switch.command_line]: expected a dictionary for dictionary value @ data['switches’]. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch.command_line/

Right I have managed to set it up in my configuration.yaml by doing the following:

  - platform: command_line
    switches:
      youview_on:
        command_on: 'echo IRCODE STANDBY | telnet 192.168.0.18 31339'
        command_off: 'echo IRCODE STANDBY | telnet 192.168.0.18 31339'
        friendly_name: Virgin On

but when I send turn off the Virgin Switch nothing happens instead if I check my log it gives me the following error:

17-03-18 17:04:09 ERROR (Thread-8) [homeassistant.components.switch.command_line] Command failed: echo IRCODE STANDBY | telnet 192.168.0.18 31339

Hello mate

Do you get any errors like mine?

Also how have you setup your command line? Do I to have to install anything on my pi for telnet to work?

Thanks.

Yeah i get errors like yours in my log but mine actually changes the channel…

thinking back i think i did install telnet… give that a go… although sounds like you already have it if you can open a session…

sudo apt-get install telnetd

you can write the equivalent in sh but i found there to be a delay when having to open script, which is why i used the cmd line approach as its far quicker.

sudo apt-get install telnetd

17-03-14 21:25:02 ERROR (Thread-6) [homeassistant.components.switch.command_line] Command failed: echo IRCODE STANDBY | telnet 192.168.0.10 31339

is what i get, but the command still works.

What version of HA are you on?

paste this on cmd line:

echo IRCODE STANDBY | telnet 192.168.0.18 31339

Does it do anything? it should change the channel but also print this to the screen:

pi@raspberrypi:~ $ echo IRCODE RECORD | telnet 192.168.0.10 31339
Trying 192.168.0.10...
Connected to 192.168.0.10.
Escape character is '^]'.
Connection closed by foreign host.

Id focus on just running the commands straight on the cmd line first, then when it works just copy that code to your switch.

It works after installing telnet ! Thanks !

Now to add channels do I have to add the code below again:

platform: command_line
  switches:
    youview_on:
      command_on: 'echo SETCH 144 | telnet 192.168.0.18 31339'
      command_off: 'echo IRCODE STANDBY | telnet 192.168.0.18 31339'
      friendly_name: Itv

Do I have to change youview_on to something else?

1 Like

Yeah you can do if you want, but it cant have any spaces in it…the switch will then be called switch.youview_on which is what they will be referred to as entities. So best change them to something more meaningful i guess i just havent yet

Here’s most of mine if you want to use them:

switch youview_off:
  platform: command_line
  switches:
    youview_off:
      command_on: 'echo IRCODE STANDBY | telnet 192.168.0.10 31339'
      command_off: 'echo IRCODE STANDBY | telnet 192.168.0.10 31339'
      friendly_name: Virgin off

switch youview_on:
  platform: command_line
  switches:
    youview_on:
      command_on: 'echo IRCODE STANDBY | telnet 192.168.0.10 31339'
      command_off: 'echo IRCODE STANDBY | telnet 192.168.0.10 31339'
      friendly_name: Virgin On

switch ok:
  platform: command_line
  switches:
    ok:
      command_on: 'echo IRCODE SELECT | telnet 192.168.0.10 31339'
      command_off: 'echo IRCODE SELECT | telnet 192.168.0.10 31339'
      friendly_name: Ok

switch record:
  platform: command_line
  switches:
    record:
      command_on: 'echo IRCODE RECORD | telnet 192.168.0.10 31339'
      command_off: 'echo IRCODE RECORD | telnet 192.168.0.10 31339'
      friendly_name: Record

switch pause:
  platform: command_line
  switches:
    pause_youview:
      command_on: 'echo IRCODE PAUSE | telnet 192.168.0.10 31339'
      command_off: 'echo IRCODE PAUSE | telnet 192.168.0.10 31339'
      friendly_name: Pause

switch mute:
  platform: command_line
  switches:
    mute_amp:
      command_on: 'curl "https://autoremotejoaomgcd.appspot.com/sendmessage?key==Mute"'
      command_off: 'curl "https://autoremotejoaomgcd.appspot.com/sendmessage?key=Mute"'
      friendly_name: Mute

switch surround:
  platform: command_line
  switches:
    surround_sound:
      command_on: 'curl "https://autoremotejoaomgcd.appspot.com/sendmessage?key==Surround"'
      command_off: 'curl "https://autoremotejoaomgcd.appspot.com/sendmessage?key==Mute"'
      friendly_name: Surround sound

switch back:
  platform: command_line
  switches:
    back_youview:
      command_on: 'echo IRCODE BACK | telnet 192.168.0.10 31339'
      command_off: 'echo IRCODE BACK | telnet 192.168.0.10 31339'
      friendly_name: Back

switch play:
  platform: command_line
  switches:
    play_youview:
     command_on: 'echo IRCODE PLAY | telnet 192.168.0.10 31339'
     command_off: 'echo IRCODE PLAY | telnet 192.168.0.10 31339'
     friendly_name: Play
switch stop:
  platform: command_line
  switches:
    stop_youview:
     command_on: 'echo IRCODE STOP | telnet 192.168.0.10 31339'
     command_off: 'echo IRCODE STOP | telnet 192.168.0.10 31339'
     friendly_name: Stop
switch fast_forward:
  platform: command_line
  switches:
    fast_forward:
     command_on: 'echo IRCODE FORWARD | telnet 192.168.0.10 31339'
     command_off: 'echo IRCODE FORWARD | telnet 192.168.0.10 31339'
     friendly_name: Fast forward

switch rewind:
  platform: command_line
  switches:
    rewind:
     command_on: 'echo IRCODE REVERSE | telnet 192.168.0.10 31339'
     command_off: 'echo IRCODE REVERSE | telnet 192.168.0.10 31339'
     friendly_name: Rewind

switch volumeup:
  platform: command_line
  switches:
    volume_up:
      command_on: 'curl "https://autoremotejoaomgcd.appspot.com/sendmessage?key=Volumeup"'
      command_off: 'curl "https://autoremotejoaomgcd.appspot.com/sendmessage?key==Volumeup"'
      friendly_name: Volume up

switch volumedown:
  platform: command_line
  switches:
    volume_down:
      command_on: 'curl "https://autoremotejoaomgcd.appspot.com/sendmessage?key==Volumedown"'
      command_off: 'curl "https://autoremotejoaomgcd.appspot.com/sendmessage?key==Volumedown"'
      friendly_name: Volume down

switch channel_28:
  platform: command_line
  switches:
    e4_youview:
      command_on: 'echo SETCH 144 | telnet 192.168.0.10 31339'
      command_off: 'echo SETCH 144 | telnet 192.168.0.10 31339'
      friendly_name: E4

switch channel_101:
  platform: command_line
  switches:
    101_youview:  
      command_on: 'echo SETCH 108 | telnet 192.168.0.10 31339'
      command_off: 'echo SETCH 108 | telnet 192.168.0.10 31339'
      friendly_name: Channel one

switch channel_102:
  platform: command_line
  switches:
    102_youview:
      command_on: 'echo SETCH 109 | telnet 192.168.0.10 31339'
      command_off: 'echo SETCH 109 | telnet 192.168.0.10 31339'
      friendly_name: Channel two

switch channel_103:
  platform: command_line
  switches:
    103_youview:
      command_on: 'echo SETCH 113 | telnet 192.168.0.10 31339'
      command_off: 'echo SETCH 113 | telnet 192.168.0.10 31339'
      friendly_name: Channel three

switch channel_104:
  platform: command_line
  switches:
    104_youview:
      command_on: 'echo SETCH 141 | telnet 192.168.0.10 31339'
      command_off: 'echo SETCH 141 | telnet 192.168.0.10 31339'
      friendly_name: Channel four
  
switch channel_105:
  platform: command_line
  switches:
    105_youview:
      command_on: 'echo SETCH 150 | telnet 192.168.0.10 31339'
      command_off: 'echo SETCH 150 | telnet 192.168.0.10 31339'
      friendly_name: Channel five 

switch comedy_central:
  platform: command_line
  switches:
    comedy_central:
      command_on: 'echo SETCH 132 | telnet 192.168.0.10 31339'
      command_off: 'echo SETCH 132 | telnet 192.168.0.10 31339'
      friendly_name: Comedy Central

switch dave:
  platform: command_line
  switches:
    dave:
      command_on: 'echo SETCH 127 | telnet 192.168.0.10 31339'
      command_off: 'echo SETCH 127 | telnet 192.168.0.10 31339'
      friendly_name: Dave

I have also added them to a group and changed the icon of each switch using customize.yaml
customize: !include customize.yaml

switch.youview_off:
 icon: mdi:power
switch.youview_on:
 icon: mdi:power
switch.surround_sound:
 icon: mdi:speaker
switch.101_youview:
 icon: mdi:numeric-1-box
switch.102_youview:
 icon: mdi:numeric-2-box
switch.103_youview:
 icon: mdi:numeric-3-box
switch.104_youview:
 icon: mdi:numeric-4-box
switch.105_youview:
 icon: mdi:numeric-5-box
switch.e4_youview:
 icon: mdi:remote
switch.comedy_central:
 icon: mdi:remote
switch.dave:
 icon: mdi:remote
switch.kodi_input_amp:
 icon: mdi:amplifier
switch.ok:
 icon: mdi:bookmark-check
switch.pause_youview:
 icon: mdi:pause
switch.play_youview:
 icon: mdi:play
switch.stop:
 icon: mdi:stop
switch.record:
 icon: mdi:record-rec
switch.testing_hyperion:
 icon: mdi:power
switch.tv_input_amp:
 icon: mdi:amplifier
switch.fast_forward:
 icon: mdi:step-forward
switch.rewind:
 icon: mdi:rewind
switch.mute_amp:
 icon: mdi:volume-off
switch.back_youview:
 icon: mdi:keyboard-backspace
switch.volume_up:
 icon: mdi:volume-high
switch.volume_down:
 icon: mdi:volume-low

then include a group for your home page:

  youview_control:
    name: Virgin Controls
    icon: mdi:kettle
    entities:
      - switch.youview_on
      - switch.youview_off
      - switch.pause_youview
      - switch.play_youview
      - switch.stop_youview
      - switch.101_youview
      - switch.102_youview
      - switch.103_youview
      - switch.104_youview
      - switch.105_youview
      - switch.dave
      - switch.comedy_central
      - switch.e4_youview
      - switch.ok
      - switch.back_youview
      - switch.record
      - switch.rewind
      - switch.fast_forward
  amp_control:
    name: Amp Controls
    entities:
      - switch.surround_sound
      - switch.volume_up
      - switch.volume_down
      - switch.mute_amp
      - switch.kodi_input_amp
      - switch.tv_input_amp

Sounds like you’re all sorted now mate! Now start adding all the buttons…

i have noticed that you need to switch the virgin box off twice to take it into standby straight away which is a little annoying, if you hit it once a message appears for 5 secs before it actually goes into standy…

Thanks alot for your help. Its up and running.

Just a quick one with the volume. Do you say to Alexa turn the "Volume Up On” ?

After installing telnet by “sudo apt-get install telnetd”
I tried the command: “echo IRCODE STANDBY | telnet 192.168.0.11 31339”

But I get the error: -bash: telnet: command not found

What could be wrong?

Just a quick one with the volume. Do you say to Alexa turn the "Volume Up On” ?

Yep, afraid so. Its a bit whack…

@Kimpan
sudo apt-get install telnetd

try sudo apt-get install telnet

It sounds like telnet didnt install properly or isnt installed. you only get that error when it cant find the
correct program. Or its still installin…

have you upgraded your pi OS recently?

sudo apt-get update
sudo apt-get dist-upgrade

try

telnet 192.168.0.11 31339

to see if you can establish a session first

Thanks

I have now done the following:
sudo apt-get install telnetd
sudo apt-get update
sudo apt-get dist-upgrade

Then when doing the “telnet 192.168.0.11 31339”

It gets stuck on “Trying 192.168.0.11…”
and finally:
telnet: Unable to connect to remote host: Connection timed out

Do I need to do something on the TIVO box for telnet to work?

Sounds like your box isn’t online or the ip is wrong g…

Hi @Rich_Paul

Just a quick question: when you ask alexa to turn on BBC News do you actually say “BBC News” or? because when I ask her to turn on BBC News it turns on the radio.

Do you experience the same?