Control TiVo box over telnet

I started working on the following a few days ago. Channel up/down should work with the default html, etc.:

1 Like

Hi! Thats great news.
How would one go about installing this component in hass.io because I dont see that file structure exposed in samba. I guess right now its only possible in hassbian?
I’m happy to help where i can as long as i can figure out how to get this installed

@milosch01 never mind the last message… I’ve installed this and running into issues. I’ve opened an issue at github. I’m happy to help on this once I can get it going and have a basic understanding. I’m a coder, but not python but im sure once i get it going I can dive in :slight_smile:

I have responded to your issue. I wonder if there is more to the error than what you included.

No more “Alexa, turn the volume up on” using routines in the alexa app!

List item

Hello mate,

Iv managed to report the state in an automation (the trick was to create another sensor which reported the state of the initial one) so thought i’d let you know

Take a look here:

sensor:
  - platform: tcp
    host: 192.168.0.10
    port: 31339
    payload: "IRCODE PAUSE\n"
  - platform: template
    sensors:
      virgin_status:
        friendly_name: 'Virgin status'
        value_template: '{{ states("sensor.tcp_sensor") }}'

automation tv lights on:
  alias: TV on - TV lights /Virgin on
  trigger:
    platform: state
    entity_id: media_player.sony_tv
    from: 'off'
    to: 'on'
  action:
    - service: homeassistant.turn_on
      entity_id: light.tv_lights
    - service: homeassistant.turn_on
      data_template:
       entity_id: >-
         {% if is_state('sensor.virgin_status', 'COMMAND_TIMEOUT') %} 
           switch.virgin_power
         {% else %}
         # do nothing
         {% endif %}

So now my box wont turn on when i try to turn a group off, and vice verca.

Would have been far easier if the there was a separate button/call to turn the box on and off, rather than a single one which toggles.

Hope this helps

Did you get it to work?

I moved close to this and didn’t have tivo in our new place so I didn’t really put in any effort.

I’ve pulled together a Tivo custom component specifically for Virgin Media boxes in the UK. I doubt if it’ll be much use to any non VM Tivo users unfortunately since it is very tied to the VM functionality.

Full details are on the GitHub repository, but in addition to the usual change channel, pause/play, turn off/on, it hooks into the VM What’s On guide in order to provide programme info. It has all the benefits and limitations of that guide, e.g. limited number of channels, but good info and the ability to show a screen grab of the currently playing programme. In addition it can automatically switch to the HD version of a channel and flick to the +1 version if available.

3 Likes

That’s tomorrow sorted! I’ll let you know how I get on :+1:

I don’t use many channels but detecting state will be useful for my automations. I have a tcp sensor atm but it sometimes takes a while to update

Let me know how you get on. On mine I’ve set scan_interval to 1. Means everything is pretty quick. Probably some better way to do that but works for me :slight_smile:

hello mate,

does this require a specific version of ha as im gettin errors. Iv not tinkered too much, but it was complaining about plusone. I tried plusone and plus_one (as per your examples which use both btw - which is correct?)

also errors regarding missin hd channels, even when i specify one… It seems to complain about missing stuff, i add it, then it complains that iv added it!

im on 69.1 which im assuming is why im getting errors

2018-07-11 23:39:25 ERROR (MainThread) [homeassistant.config] Invalid config for [media_player.virgintivo]: expected int for dictionary value @ data[‘channels’][101][‘hd_channel’]. Got None
expected int for dictionary value @ data[‘channels’][101][‘plus_one’]. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/media_player.virgintivo/

Yeah… I’ve been stuck on 0.64 since I’ve been running Ubuntu 16.04 which doesn’t have the correct version of Python to run later versions. Coincidentally I just upgraded to 18.04 yesterday and got the same errors once I then updated HA this morning. It seems that the config validator stuff will no longer let you default a value to “None” if you want to have it as an integer if populated.

Anyway I’ve resolved the problem and updated GitHub just now.

By the way it is “plus_one” :slight_smile: . I’ll tidy up the readme.

Cool thanks. Im now on the latest version of ha and just loaded your new code. noT getting the errors above now, but getting this:

2018-07-12 11:28:30 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform virgintivo
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 129, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.5/asyncio/tasks.py”, line 400, in wait_for
return fut.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/media_player/virgintivo.py”, line 137, in setup_platform
keep_connected)
File “/home/homeassistant/.homeassistant/custom_components/media_player/virgintivo.py”, line 181, in init
self.get_guide_channels()
File “/home/homeassistant/.homeassistant/custom_components/media_player/virgintivo.py”, line 204, in get_guide_channels
hd_channel = self._channels[ch_number][CONF_HDCHANNEL]
KeyError: 106

  - platform: virgintivo
    default_is_show: false
    force_hd: true
    tivos:
      1:
        name: Virgin V6
        host: 192.168.0.10
    channels:
      100:
        name: Virgin Media Previews
      101:
        name: BBC One
        hd_channel: 108
        show: true
      102:
        name: BBC Two
        hd_channel: 162
        show: true
      103:
        name: ITV
        hd_channel: 113
        show: true
        plus_one: 114
      104:
        name: Channel 4
        hd_channel: 141
        plus_one: 142
      105:
        name: Channel 5
        hd_channel: 150
        plus_one: 155

That’ll be because the example in the readme is only a partial config file - the complete one is pretty large. In the example here, only the first 5 channels are shown. When the listings are downloaded from Virgin, they contain many more channels. The first missing channel is 106 which is why that error happens.

I’ve updated the code to prevent this blowing up, but you probably want to look at the example.yaml in the code base instead. It has a full list of all the channels and you can then adjust as needed using the show attribute to pick out the channels you care about.

Really good mate, youve done well here and though of most things! Im in it just for the state, which is now all working. Iv just updated all my automations aswell.

automation back to Chromecast:
  alias: Chromecast stopped - TV input / Virgin on
  trigger:
    platform: state
    entity_id: media_player.living_room_chromecast
    from: 'playing'
    to: 'off'
  action:
    - service: homeassistant.turn_on
      entity_id: switch.tv_input,media_player.sony_tv,scene.hdmi1
    - condition: template
      value_template: "{{ is_state('media_player.virgin_v6', 'off') }}"
    - service: switch.turn_on 
      entity_id: switch.virgin_power


automation switch to tv:
  alias: TV HDMI1 on - HDMI 1 Amp on
  trigger:
    platform: template
    value_template: "{{ is_state_attr('media_player.sony_tv', 'media_title', 'HDMI 1') and is_state('media_player.playstation_4', 'off') }}"
  action:
    - service: switch.turn_on
      entity_id: switch.tv_input
    - condition: state
      entity_id: media_player.virgin_v6
      state: 'off'
    - service: switch.turn_on
      entity_id: switch.virgin_power    

Im still using my telnet switches to turn it on/off - i may update them to use this at some point.

great work dude - raise a PR and get it in .74 :slight_smile:

Pretty sure you can only make one telnet connection to the box at any time, so looks like I’ll have to migrate everything on to your component sooner to get it all working.

Is there anyway of changing how you select a channel? My current ones are switches meanin emulated hue exposes them to alexa. Correct me if wrong, I’m not sure you can set the channel using an input select/media player using emulated hue and alexa, not without some tinkering?

Your component works fine until I use my old switches, which then takes priority over your component… I need my switches but your state functionality,but incorporated into a single component. Could you set priority of each component when the user interacts with it?

On the telnet bit, yes only one thing can connect at a time. By default my component will make a permanent connection. However you can set the keep_connected attribute to false to make it disconnect after each check/command to allow it to play nicer with anything else you’ve got running.

For your other question, are you referring to the telnet switch and your “tv_lights” automation? I haven’t investigated how the telnet switch works in conjunction with this. Try setting keep_connected to false and see if that makes it play a bit nicer. I don’t know that I can have switches in the same component. I tried before and all that happened was that it created additional media_player devices with the switch names. Probably some way but currently beyond me. Let me know if it works or not and if not, I’ll try to poke it over the weekend.