core icon indicating copy to clipboard operation
core copied to clipboard

Cannot switch channels added as sources to HomeKit TV

Open squirtbrnr opened this issue 2 years ago • 4 comments

The problem

With the recent changes to the Sony Bravia TV integration in 2023.2, I can no longer change channels in HomeKit.

I used to be able to set a customize option for the entity under the customize: section where I can list out the sources or channels that I want. After the recent changes, the sources show up in the list in HomeKit, but I cannot switch to any of them except for the external sources like HDMI1, HDMI2, Video 1, etc. I believe this has to do with the channels now listed under the “Browse Media” or media sources for the TV entity as well as the change in service calls and how to address media sources because these same sources error out with a “failed to call, no source found by that name” error if they are in the dropdown list of the standard media player Lovelace card. But I can change channels and sources of the TV from Home Assistant through service calls or browsing media/channels. I cannot select or change any channels of the TV in HomeKit. The TV is setup in the HomeKit integration in accessory mode and the media player is of device class type TV (both as required and laid out in the documentation).

What version of Home Assistant Core has the issue?

2023.2.4

What was the last working version of Home Assistant Core?

2023.1

What type of installation are you running?

Home Assistant Container

Integration causing the issue

HomeKit

Link to integration documentation on our website

https://www.home-assistant.io/integrations/homekit/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

squirtbrnr avatar Feb 15 '23 02:02 squirtbrnr

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of homekit can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign homekit Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


homekit documentation homekit source (message by IssueLinks)

home-assistant[bot] avatar Feb 15 '23 02:02 home-assistant[bot]

I have the same issue, the sources are available when just add TV to Home App, but they will disappear sooner or later... So I have to re-add(remove from Home, reload Homekit integration, then add it back) it to make it work again, for a while..

sephrioth avatar Feb 15 '23 03:02 sephrioth

Since the Bravia TV Integration has the Channel list moved to the Media Browser instead of the source list it is No More possible to select a Channel in HomeKit.

Can you please add the feature that HomeKit Integration Can took the Channels from the Media Browser?

BR Tom

TomF79 avatar Feb 15 '23 04:02 TomF79

As i said there, HomeKit media player sources is not designed to store channel list and only creates problems.

But if you really need it, this is workaround:

Wrap your bravia media player in universal integration, override select_source command and source attribute:

configuration.yaml (replace media_player.sony_tv to your):

media_player:
  - platform: universal
    name: sony_tv_channels
    unique_id: sony_tv_channels
    device_class: tv
    children:
      - media_player.sony_tv
    commands:
      select_source:
        service: media_player.play_media
        data:
          media_content_type: channel
          media_content_id: "{{ source }}"
        target:
          entity_id: media_player.sony_tv
    attributes:
      source: media_player.sony_tv|media_channel

Manually define channels you want list in customize (name should match channel name in media browser):

customize.yaml:

media_player.sony_tv_channels:
  source_list:
    - Channel 1
    - BBC
    - HBO
    - CNN
    - More4
    - CBS Reallity
    - .....

Then pass media_player.sony_tv_channels into HomeKit.

Drafteed avatar Feb 27 '23 04:02 Drafteed

Thanks for providing a work around. However, because sources and channels were separated and treated differently, you cannot select inputs (HDMI 1, HDMI 2, Video 1, etc) that are in the source list of the universal media player.

Channels appear in the media browser and inputs appear in the source list of a media player of type tv. Because the universal media player sets the media content type as "channel" under the elect source command, then sources such as HDMI 1 are not valid.

So with this template what I have now is one media player which is the Bravia tv integration which has inputs in the source list, and one media player which is the universal media player integration which has channels in the source list. Both work independently, but how do I get a single source list with both inputs and channels? this is what existed previously and worked just fine in both HA and HomeKit.

squirtbrnr avatar Feb 27 '23 23:02 squirtbrnr

However, because sources and channels were separated and treated differently, you cannot select inputs (HDMI 1, HDMI 2, Video 1, etc) that are in the source list of the universal media player.

You can create script that will take a source as input, check it against the list of sources and make a media_player.select_source service call if the source is an input, or media_player.play_media otherwise.

Not tested.

script:

alias: Bravia TV select channel or input
fields:
  tv:
    name: Bravia TV media player
    required: true
    selector:
      entity:
        integration: braviatv
        domain: media_player
  source:
    name: Source
    required: true
    selector:
      text:
sequence:
  - if:
      - condition: template
        value_template: "{{ source in state_attr(tv, 'source_list') }}"
    then:
      - service: media_player.select_source
        data:
          source: "{{ source }}"
        target:
          entity_id: "{{ tv }}"
    else:
      - service: media_player.play_media
        data:
          media_content_id: "{{ source }}"
          media_content_type: channel
        target:
          entity_id: "{{ tv }}"
mode: single

configuration.yaml:

media_player:
  - platform: universal
    name: sony_tv_channels
    unique_id: sony_tv_channels
    device_class: tv
    children:
      - media_player.sony_tv
    commands:
      select_source:
        service: script.bravia_tv_select_channel_or_input
        data:
          tv: media_player.sony_tv
          source: "{{ source }}"
    attributes:
      source: media_player.sony_tv|media_channel

Or you can just use two media players in HomeKit and not bother..

Drafteed avatar Mar 20 '23 01:03 Drafteed

It might be better to put it in the FAQ in the Bravia page :)

keith-kl avatar Mar 25 '23 01:03 keith-kl

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.