Hi everyone,
I’m using the very nice App ControllerX (ControllerX. Bring full functionality to light and media player controllers) to control the volume of the current playing media player.
But a problem one of my media players (an old Harman Kardon) doesn’t have any way to control it but with IR-remote. So I setup an IR-sender with esphome but problem ControllerX expects a media_player entity so it can use the services set_volume(or in the dev version volume_up/down).
After searching I didn’t found a way to create my own media_player entity like you do with switches and lights (templating) So I started to create my own custom_component
At this moment it doesn’t have all the actions that a normal media_player has but it’s usable.
There’s one downside: to use this component you need to override all the template entities!
(if this is wrong please correct me)
How to install:
- Create a ‘custom_components’ folder in your config folder(if it doesn’t exist)
- Create ‘template’ folder in the custom_components folder
- Copy all the file from https://github.com/home-assistant/core/tree/dev/homeassistant/components/template to this folder (I read that this is needed otherwise the component isn’t overriden)
- Copy my media_player.py to this folder
- Create your config like following example:
media_player:
- platform: template
media_players:
receiver:
friendly_name: Receiver
current_source_template: "{{ states('input_text.selected_source') }}"
value_template: >
{% if is_state("input_boolean.receiver_on", "on") -%}
on
{%- else -%}
off
{%- endif %}
turn_on:
service: switch.turn_on
data_template:
entity_id: switch.receiver_on
turn_off:
service: switch.turn_on
data_template:
entity_id: switch.receiver_off
volume_up:
service: switch.turn_on
data_template:
entity_id: switch.volume_up
volume_down:
service: switch.turn_on
data_template:
entity_id: switch.vol
input_templates:
source 1:
service: input_boolean.turn_on
data_template:
entity_id: input_boolean.source_1
source 2:
service: input_boolean.turn_on
data_template:
entity_id: input_boolean.source_2
Hope someone finds this usefull and if there’s anything wrong create a issue!