architecture icon indicating copy to clipboard operation
architecture copied to clipboard

Change TV channel by name and not only by number

Open tulindo opened this issue 5 years ago • 10 comments

Context

Currently HA (at least samsungtv) can only switch TV channel by channel number and not by channel name. I developed and published on pypi this simple project https://github.com/tulindo/tvchannellist. This module, given a channel name returns the current LCN. It currently supports Italy and US (other countries can easily be added). I grab the idea from an alexa skill developed for controlling samsungtv's and I tried to make something modular and easily extendable.

Proposal

My original idea was to simply add this module in the requirements for the samsungtv and implement a PR to add support for changing TV channel by name. but discussing with @escoand (samsungtv code owner) he told me that this can be an integration (but honestly I did not unserstan that much). @pvizeli on discord suggested me to open an architectural issue. Here it is.

Any suggestion? Thanks, Paolo

Consequences

Ability to change TV channel by name for all media player TV platform that currently allows only to change channel by number.

tulindo avatar Jan 14 '20 16:01 tulindo

This could be a new integration similar to how we have media_extractor. The media_extractor integration works by sending url of online media (ie a Youtube URL) and it will then forward that call to the media palyer with the video url extracted.

balloob avatar Jan 14 '20 17:01 balloob

@tulindo yes, this was what I basically meant.

escoand avatar Jan 14 '20 17:01 escoand

@balloob excellent! So basically media_extractor can be "used" by other integrations. Do you have an example of such a user?

tulindo avatar Jan 14 '20 18:01 tulindo

@balloob excellent! So basically media_extractor can be "used" by other integrations. Do you have an example of such a user?

From how read it, media_extractor itself is one such integration (see media_extractor/__init__.py).

An implementation could be based on that.

ties avatar Jan 14 '20 18:01 ties

@balloob , @escoand and @ties... I'm not sure I unserstood. I try to explain with an example. Currently alexa integration when requested to change channel on a TV invokes the media_player.play_media service with channel as payload. samsungtv platform implementation of play_media service accepts only positive integers as payload, if a channel name is received... simply does nothing Will the media_extractor like approach allow the samsungtv's play_media service to accept also channel names?

tulindo avatar Jan 14 '20 19:01 tulindo

@ochlocracy I begun working on the tvchannellist module to integrate it into HA in order to change TV channels by name using alexa. ChangeChannel's implementation is currently invoking the play_media service of the controlled entity with the channel as input. My TV is a samsung TV and currently samsungtv platform (many others too) does not support to change channels by name. when invoked with channel name... simply does nothing. My original intent was to change the samsungtv's platform implementation of the play media service in order to allow TV channels to be changed by name (so that alexa integration will not have to be changed) @balloob suggested to implement a new integration similar to the the media_extractor. This means that in order to change channel by name the alexa implementation oh the changechannel service will have to be changed. What do you think about this? IMHO this will end up in a big complexity for the alexa's implementation.

tulindo avatar Jan 17 '20 14:01 tulindo

@ochlocracy another question. Even if we will make the alexa component to call this new integration to change channel by name... what about current tv platforms (like webostv) that can change channel by name using platform's own features?

tulindo avatar Jan 17 '20 15:01 tulindo

Regarding Alexa support for this; I would probably propose taking a look at the media_player component in the process, before choosing to directly integrating with it a service call. Specifically for the reason above that some TV platforms already support channel names.

The Alexa integration is using the the "base" components or "lowest common denominator" when implementing devices. To determine device support for something like channel name or number, Alexa has to rely on the support constants and service calls in the component/integration. I would propose implementing additional properties and methods in the media_player to report support for channels.

In my opinion the media_player component looks more like an ipod than a smartTV it could benefit from an update.

ochlocracy avatar Jan 17 '20 20:01 ochlocracy

I've always pondered if it would be good to split the entity into two. One being a rendering entity (sink) one being a source entity. A tv with built on tuner would then be two entities. One for the rendering (display to user) with source selection. One being the source (tuner) with channel selection.

That way the built in features we be treated same as external stuff.

elupus avatar Jan 17 '20 21:01 elupus

@ochlocracy I do agree. I started development of tvchannellist module as an attempt to allow all television platform to support changing channel by name. IMHO HA is missing a `television' integration

tulindo avatar Jan 17 '20 23:01 tulindo

This architecture issue is old, stale, and possibly obsolete. Things changed a lot over the years. Additionally, we have been moving to discussions for these architectural discussions.

For that reason, I'm going to close this issue.

../Frenck

frenck avatar May 11 '23 13:05 frenck