A HACS integration to manage TV channel mappings.
It comes with presets for Hungarian providers (HU One, HU Digi), but supports custom channel lists via the "Add Channel" feature, allowing you to build your own mapping for any provider.
Features
- Select Provider: Choose your TV provider during configuration.
- Channel Mapping: Automatically loads channel numbers based on the selected provider.
- Customization: Rename channels to your liking via Options.
- Sensor: Exposes a
sensor.tv_channel_mappingwith attributes containing the full map (Name -> Number) for use in automations and scripts.
Installation
Option 1: HACS (Recommended)
- Open HACS in Home Assistant.
- Go to "Integrations" section.
- Click the 3 dots in the top right corner -> Custom repositories.
- Add the URL of this repository.
- Category: Integration.
- Click Add.
- Now search for "TV Channel Mapping" in HACS and install it.
- Restart Home Assistant.
Option 2: Manual
- Download the repository.
- Copy the
custom_components/tv_channel_mappingfolder to your Home Assistantconfig/custom_components/directory. - Restart Home Assistant.
Configuration
- Go to Settings -> Devices & Services.
- Click Add Integration button.
- Search for TV Channel Mapping and select it.
- Select your provider (e.g., HU Digi or HU One).
- Select the Target TV (The
media_playerentity you want to control).
Usage
Voice Control
The integration automatically registers voice commands (English and Hungarian). You can control the configured TV by saying:
- "Switch TV to RTL"
- "Change to channel TV2"
- "Put on Discovery Channel"
The channel name is matched against your active channel list.
External Integrations (OpenAI, Scripts)
For third-party integrations like Extended OpenAI Conversation, using the voice intent might not be enough. The integration exposes a dedicated service to allow LLMs to control the TV reliably without guessing channel numbers.
Service: tv_channel_mapping.tune_channel
Parameters:
- channel_name (Required): The name of the channel to match (e.g., "RTL", "HBO").
Example YAML:
service: tv_channel_mapping.tune_channel
data:
channel_name: "TV2"
Automatic AI Discovery (Recommended):
On Home Assistant 2024.6+, this integration automatically registers a tv_channel_mapping_tune_channel tool. Your AI agent should see this automatically without any configuration!
OpenAI Prompt Example:
"Use
tv_channel_mapping.tune_channelwhen the user asks to change the TV channel. Pass the channel name as the argument. If you are unsure about the channel name, or if the user asks for a list, usetv_channel_mapping.get_available_channelsfirst."
Method B: Direct Function Configuration (Best for Extended OpenAI)
If automatic discovery doesn't work, you can explicitly define the function in Extended OpenAI Conversation settings.
- Go to Extended OpenAI Conversation configuration.
- Find the Functions section.
- Add the following YAML block:
- spec:
name: tune_channel
description: Switches the TV to a specific channel by name. Use this whenever the user asks to change the channel.
parameters:
type: object
properties:
channel_name:
type: string
description: The name of the channel (e.g. RTL, HBO, Discovery).
required:
- channel_name
function:
type: script
sequence:
- service: tv_channel_mapping.tune_channel
data:
channel_name: "{{ channel_name }}"
- spec:
name: get_available_channels
description: Returns a list of all available TV channels. Use this if you need to know what channels are available or if the user asks for a list.
function:
type: script
sequence:
- service: tv_channel_mapping.get_channel_list
response_variable: _function_result
- Save. The AI can now directly control the TV! No scripts needed.
Sensor Entity
The integration creates sensor.tv_channel_mapping. The state is the current provider name. The attributes contain the channel mapping.
Example Automation Action:
service: media_player.play_media
target:
entity_id: media_player.my_tv
data:
media_content_id: "{{ state_attr('sensor.tv_channel_mapping', 'channels')['RTL'] }}"
media_content_type: channel