Control TiVo box over telnet

thanks thats great will try it out later

@Bertbert just finished typing out the switches and automations from @Rich_Paul for Alexa control do you want a copy to put into the package so others can have a copy to save them having to type it all out?

Donā€™t know much about Alexa integration, but if you want to send them to me, Iā€™ll stick them on as an example in the repository.

got a fix for that if you havenā€™t figured it out. I say ā€œfixā€ it just removes them from the logbook entries
same fix removes them from the history graph

this isnā€™t required if you are using home assistant cloud

@Bertbert here is a link to the yaml files and an install instruction text file they are in .rar format

Quick documentation suggestion.
Currently the readme says:

[code]# Usage

  • Drop the file into the custom_components/media_player directory.
  • Edit your configuration file to add the virgintivo platform.
    [/code]

It took me a bit of searching to realise that I had to create a media_player section.
In the end I did it by creating a virgintivo.yaml file in the HASS directory and then referrring to it via !include

# Virgin Tivo
media_player: !include virgintivo.yaml

Thanks Gary. Iā€™ve put this into the repository as an example of Alexa automation.

Fair comment :smile:

Iā€™ve updated the example.yaml and readme to add in the media_player: bit.

Great - thanks for that - for the next one along at least.

Another idea - if the channel list and device/package configuration were kept in separate files then it would mean that people could more easily import the updated channel list ā€¦ by simply copying the file over rather than having to merge back their personal set-up changes.
My guess ā€¦ without any insight of how other users do it ā€¦ is that the channel list is not changed by end-users.

Right so think I might have nailed advert skipping durations based on the channel you are watching, when pausing live TV and watching a recording from the HD.

  • Channel 4 - 4 mins
  • ITV - 3.5 mins (can change depending what TV progamme is showing - next challenege?)
  • Channel 5/E4 - 5 mins

If the box is playing a recording from the hard drive, home assistant reports it as off, so it canā€™t detect chanel/recording info. However you can still send commandsā€¦

Now, all i say is ā€œAlexa, skip the breakā€ and it skips the correct length. I also have ā€œAlexa, skip the Advertā€ for 5 min breaks, which is only needed if im playing something from my hard drive/my shows section.

Skipping adverts from paused live TV

  • Code works with itv, ch4, ch5 and e4, other channels can be added as new automations or by adding another or is_state_attr('media_player.virgin_v6', 'media_title', 'E4') to the current automations
  • one switch or alexa routine (ā€œAlexa, skip the breakā€ which turns the skip_break2 switch on) will skip the correct advert length based on what channel you are watching
  • If youā€™re on a different channel, you can only use 4 or 5 min ad breaks until you add them as additional automations

skipping adverts when playing a recording from my shows

  • As we have no idea what the channel is on, the 2 switches will either skip a Short advert (4 min) or a Long advert (5 min)

#
#
#                   SKIPPING ADVERTS
#
#                   CREATE EMPTY SWITCHES TO ACT AS TRIGGERS FROM ALEXA FOR SKIPPING THE BREAK. THESE WILL TURN OFF AUTOMATICALLY ONCE THE AUTOMATION HAS RUN SO IT CAN BE RE-TRIGGERED
#
#         
#
#
#
#
#
#
#
switch skipthebreak2:
  platform: command_line
  switches:
    skip_break2:
      command_on: ''
      command_off: ''
      friendly_name: Short advert


        
switch skipthebreak:
  platform: command_line
  switches:
    skip_break1:
      command_on: ''
      command_off: ''
      friendly_name: Long advert
        
#
##
#
#
#
#
#                    THESE WILL ONLY FIRE WHEN WATCHING A RECORDING FROM THE HARD DRIVE - THE BOX IS REPORTED AS OFF DURING THIS TIME SO WE USE THAT AS A CONDITION
#
#         
#
#
#
#
#
#
#
       
automation skip break all:
  - alias: Virgin - skip 3.5min
    trigger:
      - platform: state
        entity_id: switch.skip_break2
        from: 'off'
        to: 'on'
    action:
      - condition: template
        value_template: "{{ is_state('media_player.virgin_v6', 'off') }}"      
      - service: media_player.virgintivo_ircode
        data:
         command: advance
         repeats: 7
         entity_id: media_player.virgin_v6
      - service: homeassistant.turn_off
        entity_id: switch.skip_break2
        
automation skip break all 5:
  - alias: Virgin - skip 5min
    trigger:
      - platform: state
        entity_id: switch.skip_break1
        from: 'off'
        to: 'on'
    action:
      - condition: template
        value_template: "{{ is_state('media_player.virgin_v6', 'off') }}"  
      - service: media_player.virgintivo_ircode
        data:
         command: advance
         repeats: 10
         entity_id: media_player.virgin_v6
      - service: homeassistant.turn_off
        entity_id: switch.skip_break1
#
##
#
#
#
#         THESE WILL ONLY FIRE WHEN WATCHING A LIVE,PAUSED PROGRAMME - THE BOX IS REPORTED AS PLAYING DURING THIS TIME SO WE CAN GET THE CHANNEL - AND USE BOTH AS A CONDITION
#
#         
#
#
#
#
#
#
       
automation skip break ITV:
  - alias: Virgin - skip ITV break
    trigger:
      - platform: state
        entity_id: switch.skip_break2
        from: 'off'
        to: 'on'
    action:
      - condition: template
        value_template: "{{ is_state_attr('media_player.virgin_v6', 'media_title', 'ITV HD') }}"     
      - condition: template
        value_template: "{{ is_state('media_player.virgin_v6', 'playing') }}"     
      - service: media_player.virgintivo_ircode
        data:
         command: advance
         repeats: 7
         entity_id: media_player.virgin_v6
           
      - service: homeassistant.turn_off
        entity_id: switch.skip_break2
       
automation skip break C4:
  - alias: Virgin - skip C4 break
    trigger:
      - platform: state
        entity_id: switch.skip_break2
        from: 'off'
        to: 'on'
    action:
      - condition: template
        value_template: "{{ is_state('media_player.virgin_v6', 'playing') }}" 
      - condition: template
        value_template: "{{ is_state_attr('media_player.virgin_v6', 'media_title', 'Channel 4 HD') }}"    
      - service: media_player.virgintivo_ircode
        data:
         command: advance
         repeats: 8
         entity_id: media_player.virgin_v6
      
      - service: homeassistant.turn_off
        entity_id: switch.skip_break2
       
automation skip break e4:
  - alias: Virgin - skip e4/5 break
    trigger:
      - platform: state
        entity_id: switch.skip_break2
        from: 'off'
        to: 'on'
    action:
      - condition: template
        value_template: "{{ is_state('media_player.virgin_v6', 'playing') }}" 
      - condition: template
        value_template: "{{ is_state_attr('media_player.virgin_v6', 'media_title', 'Channel 5 HD') or is_state_attr('media_player.virgin_v6', 'media_title', 'E4') }}"    
      - service: media_player.virgintivo_ircode
        data:
         command: advance
         repeats: 10
         entity_id: media_player.virgin_v6
      
      - service: homeassistant.turn_off
        entity_id: switch.skip_break2  
#
#
#         WE DO NOT KNOW WHAT CHALLEN THE BOX IS ON SO USE THE ORIGINAL COMMANDS - SKIP THE BREAK FOR 4 MINS AND SKIP THE ADVERT FOR 5 MIN
#
#         
#
#
#
#
#
#
automation 5 min no channel :
  - alias: Virgin - skip min 5 break (chl unknown)
    trigger:
      - platform: state
        entity_id: switch.skip_break1
        from: 'off'
        to: 'on'
    action:
      - condition: template
        value_template: "{{ is_state('media_player.virgin_v6', 'playing') }}" 
      
      - condition: template
        value_template: "{{ not is_state_attr('media_player.virgin_v6', 'media_title', 'E4') or not is_state_attr('media_player.virgin_v6', 'media_title', 'Channel 5 HD') or not is_state_attr('media_player.virgin_v6', 'media_title', 'Channel 4 HD') or not is_state_attr('media_player.virgin_v6', 'media_title', 'ITV HD') or not is_state_attr('media_player.virgin_v6', 'media_title', 'E4') }}" 
      
      - service: media_player.virgintivo_ircode
        data:
         command: advance
         repeats: 10
         entity_id: media_player.virgin_v6
      
      - service: homeassistant.turn_off
        entity_id: switch.skip_break1
        
automation 4 min no channel :
  - alias: Virgin - skip min 4 break (chl unknown)
    trigger:
      - platform: state
        entity_id: switch.skip_break2
        from: 'off'
        to: 'on'
    action:
      - condition: template
        value_template: "{{ is_state('media_player.virgin_v6', 'playing') }}" 
      
      - condition: template
        value_template: "{{ not is_state_attr('media_player.virgin_v6', 'media_title', 'E4') or not is_state_attr('media_player.virgin_v6', 'media_title', 'Channel 5 HD') or not is_state_attr('media_player.virgin_v6', 'media_title', 'Channel 4 HD') or not is_state_attr('media_player.virgin_v6', 'media_title', 'ITV HD') or not is_state_attr('media_player.virgin_v6', 'media_title', 'E4') }}" 
      
      - service: media_player.virgintivo_ircode
        data:
         command: advance
         repeats: 8
         entity_id: media_player.virgin_v6
      
      - service: homeassistant.turn_off
        entity_id: switch.skip_break2
        
        
      - condition: template
        value_template: "{{ not is_state_attr('media_player.virgin_v6', 'media_title', 'E4') or not is_state_attr('media_player.virgin_v6', 'media_title', 'Channel 5 HD') or not is_state_attr('media_player.virgin_v6', 'media_title', 'Channel 4 HD') or not is_state_attr('media_player.virgin_v6', 'media_title', 'ITV HD') or not is_state_attr('media_player.virgin_v6', 'media_title', 'E4') }}" 
#
#
#
#         END
#
#
#
1 Like

I donā€™t know if Virgin have done this for all regions ā€¦ but BBC2HD has now moved to 102 so the automatic swap to HD channel list will need a small update.

Edit: Just checked on GitHub and I see that you made the change yesterday. Well done.

Hi Gary,

Iā€™ve followed these instructions having initially found Bertā€™s github for the component. Iā€™ve got the component installed on hassio but Iā€™m struggling with getting the alexa part of the setup working.

What do you need to see in order to know what Iā€™ve done wrong?

Thanks

Jason

If you find that Alexa appears to be imported the list but nothing appears in the Alexa app then have you tried reducing the number of channels that are listed in each of automations.yaml and switch.yaml ?
I tried it with the full set and never managed to get them to import into Alexa - but then reduced to the first 20 or so and it then appears.

However, I am now stuck at the next problem ā€¦ the automations do not make the box change channel.
My first thought was that the entity_id should be virgintivo not virgin (so that it matches what is in the ā€œplatformā€ but that did not work for me.

  - alias: BBC 1
    trigger:
      - platform: state
        to: 'on'
        entity_id: switch.101_virgin
    action:
      - service: media_player.select_source
        data:
         entity_id: media_player.virgintivo
         source: BBC One
      - service: homeassistant.turn_off
        entity_id: switch.101_virgin

(above is with my change)
My next thought ā€¦ I have 2 TiVo boxes (like in the original .yaml) ā€¦ so how does the automation know which one to apply it to.
I tried changing the entity_id to media_player.virgintivo.tivos.1 or media_player.virgintivo.1 but that does not work (and it generates an error in the logs when triggering the automation).

I read https://www.home-assistant.io/getting-started/automation-2/ but it did not help me in this case.

Edit:
In my case - configuration.yaml has
media_player: !include virgintivo.yaml

and the top of virgintivo.yaml looks like this
- platform: virgintivo
default_is_show: false
#show_packages: Free-to-air,Player,Mix,Fun,Full House,Premium,Pay-per-view
show_packages: Full House
default_is_hd: true
scan_interval: 5
tivos:
1:
name: Virgin V6
host: TIVO-Cxxxxxxx
force_hd: true
2:
name: Virgin Tivo
host: TIVO-Cyyyyyyy
force_hd: true

Yeah I was trying to do the whole list. I donā€™t really care about the majority of channels so it probably makes sense to try and cut down the list to what I actually regularly use. Thanks, Iā€™ll give it a go this evening.

@PaulWebster, you identify the boxes using the entity_id. Try using media_player.virgin_v6 and media_player.virgin_tivo.

Thanks - I had just made it work by changing the name from ā€œVirgin V6ā€ to ā€œVirginLoungeā€ (no spaces) in virgintivo.yaml and then putting media_player.virginlounge in automations.yaml

Still leaves a question though ā€¦ although it does not apply to me ā€¦ how would someone with 2xTiVo and 2xEcho associate each Echo with a different TiVo?

Well Iā€™ve cut down the list of channels to what I think will actually be used but Alexa (or the buttons on the hassio overview) still does nothing when I try to activate a switch. :frowning:

Regarding your multiple echo + multiple tivo, well I have my box as an item in my Alexa app now and Iā€™ve been able to add it to a room, so presumably it would use the box in the room that the echo is associated with. Iā€™d be happy to test it out for anyone who cares as I do have two V6 boxes, if I could actually get my commands to workā€¦

You might have the same problem as I did with matching the TiVo name between the configuration files.
Can you shows the top few lines of your virgintivo.yanl and automation.yaml ?

I am new to HASS but pleased to report that I have this working (Alexa-HASS-TiVo).
Thanks.

I have been wondering about simplifying things but I donā€™t know if this is possible.
At the moment each channel is listed 3 times - switch.yaml (for Alexa), virgintivo.yaml (for the component that talks to the TiVo) and automation.yaml (to provide the join between the other two).
Is there a way to add more info into switch so that it can pass parameters that would be used by automation so that automation does not need a list of channels but instead can generate what is needed to call the virgntivo custom module?

This would make it easier when adding/removing channels and would also remove the long list of automations from the HASS web interface.

Also - for others who have had to cut down the list of channels to make it small enough for Alexa to import ā€¦ I removed from switch.yaml all of the HD channels where there is also an SD version and have auto-switch to HD enabled in the custom module.