I had one of the inputs working but, after messing around to try to get them all to work I brok it and can’t figure out how to get it back. Unfortunately I couldn’t get the volume to show up in the remote app or as a media player in the remote app.
Here’s my universal media player config and what I did to get this to at least show. If anybody is interested in trying a few different configs.
I was able to get my three TVs showing up in HomeKit with selectable sources. I based the media players around the Harmony remote. This took me a while so I wanted to share my working config. It seemed to be very picky about quotes and types.
media_players.yaml:
- platform: universal
name: Media Room TV
commands:
turn_on:
service: remote.turn_on
entity_id: remote.media_room_harmony
data:
activity: Watch Computer
turn_off:
service: remote.turn_off
entity_id: remote.media_room_harmony
select_source:
service: remote.turn_on
data_template:
entity_id: remote.media_room_harmony
activity: >-
{% if source == 'Computer' %}
Watch Computer
{% elif source == 'Apple TV' %}
Watch Apple TV
{% elif source == 'Blu-ray' %}
Watch Blu-ray
{% elif source == 'Playstation' %}
Play PS4
{% elif source == 'Xbox' %}
Play Xbox One X
{% elif source == 'Nintendo Switch' %}
Play Nintendo Switch
{% else %}
Watch Computer
{% endif %}
attributes:
state: remote.media_room_harmony
source: input_select.media_room_tv
input_selects.yaml:
media_room_tv:
name: Media Room TV Input
options:
- Computer
- Apple TV
- Blu-ray
- Playstation
- Xbox
- Nintendo Switch
- Power Off
automations.yaml:
- id: '1356121322963'
alias: Update Media Room Input Select
trigger:
platform: state
entity_id: remote.media_room_harmony
condition: []
action:
- service: input_select.select_option
data_template:
entity_id: input_select.media_room_tv
option: >-
{% if trigger.to_state.attributes.current_activity == 'Watch Computer' %}
Computer
{% elif trigger.to_state.attributes.current_activity == 'Watch Apple TV' %}
Apple TV
{% elif trigger.to_state.attributes.current_activity == 'Watch Blu-ray' %}
Blu-ray
{% elif trigger.to_state.attributes.current_activity == 'Play PS4' %}
Playstation
{% elif trigger.to_state.attributes.current_activity == 'Play Xbox One X' %}
Xbox
{% elif trigger.to_state.attributes.current_activity == 'Play Nintendo Switch' %}
Nintendo Switch
{% else %}
Power Off
{% endif %}
customize.yaml:
media_player.media_room_tv:
friendly_name: Media Room TV
source_list: [Computer,Apple TV,Blu-ray,Playstation,Xbox,Nintendo Switch]
device_class: tv
I could never get it working properly when using the input_select to define the source_list. The sources only started reliably showing up when I added them explicitly to cutomize.yaml as above. I still use the input_select to store the current source via automation.
Have not yet tried volume up/down but that should be straightforward to add via harmony as well.
For the record, I do see these messages in the log sometimes:
2019-05-29 12:51:34 WARNING (SyncWorker_0) [homeassistant.components.homekit.type_media_players] media_player.living_room_tv: Sources out of sync. Restart HomeAssistant
But they appear to be harmless and do not affect the functionality. Not sure why they are being triggered though. I was seeing them when using the input_select for the source_list as well.
Right, I’m having issues with this as well. rPi 3, Hassio, 0.94.x
I too am getting the following errors:
2019-05-29 12:51:34 WARNING (SyncWorker_0) [homeassistant.components.homekit.type_media_players] media_player.living_room_tv: Sources out of sync. Restart HomeAssistant
…but they do not seem completely harmless. After initially working correctly, with all sources appearing as expected in the Home app, after a while (usually if I’ve left home and come back again) the sources get all mucked up. In each media player in Home the sources do not appear correctly and instead start appearing as separate Homekit entities (with little house icons, and no selectable options). This is when I usually notice the error message appearing, although I need to test further to confirm they are linked. Restarted Home Assistant seems to fix it temporarily but after a while it mucks up again.
I’m using a Broadlink RM3 for my IR control with script selection:
Try removing source_list from the attributes of your media player. You are defining the source_list explicitly in your customize.yaml so you don’t need it there. I had similar problems when that was linked to the input_select. Things have been stable with the config I posted.
You could also try removing the children from your media players, unless there is a specific reason why you’re defining them. For the purposes of HomeKit I’m not sure they really affect anything since you’re overriding all the available methods anyway.
Also, for the record, I have an automation that starts up HomeKit 5 minutes after HA starts. That makes sure all the other components and entities are loaded. Just something else you could try…
Thanks! Had to delete and re-add my media players to homekit to get it working but so far so good, have tried a few restarts and connecting/disconnecting to wifi and seems much more stable!
So, I think I know the answer, but I think I’m trying to do this backwards.
I dont use Homekit to control devices, I do use a homekit controller in HA to control a couple things, such as local control for my ecobee thermostats. I saw that my vizio tv’s are now homekit compatible. I’ve been able to add them to the Homekit controller in HA. But they have no entity’s. I believe that’s just because The homekit controller does not have a device class for TV? I really just want to be able to know if my tv is on or off, so that I can do other automatons in HA based on that.
I do have an apple TV and I can add the TV to my “real” homekit, but it just seems like an extra layer. Any suggestions?
I would just skip the HomeKit controller for your Vizio TV. Looks like there is a Vizio HA component, if you use that instead then you should get a media_player entity from which you can base automations, or use the media_player to create other virtual entities (e.g. input_boolean for simple on/off).
Ha, Actually I do use the vizio component already and it works pretty good. The setup is a little more complex than other setups, so for some users it’s a bit too much. Whereas the homekit setup is very simple. Also, for me at least after a few days of being “off” my logs get flooded with messages about being unable to contact the vizio service. When the firmware on my TVs autoupdate, they often break in HA until the next HA update of the vizio component. Sometimes I have to go through the vizio pairing setup again.
Was hoping to try out the homekit controller option to see if it was more stable. It seems to be rock solid with with my ecobee’s. I’m not looking for much of a remote control setup, but… if I was it would be nice to be able to do some basic contols without having to set up extra input booleans, selects, etc.
I use the Vizio component as well. It does work pretty well. I haven’t had any issues with needing to re-pair with updates to firmware or HA.
What I find lacking is the the “Source” listing in the vizio component doesn’t pull the source names from the TV. You only get HDMI-1, CAST, etc. ,not the names that are set in the TV - Xfininty, Fire TV, etc
I did look at the “homekit_controller-entity-map” file in .storage and it pulls the source names from the TV, so I am hoping that maybe if we get a Homekit controller for TV’s, it would be easily updated as sources are added to my TV’s
So I set up my tv on Homekit, I turned on the TV with the TV remote and turned it off with the TV remote. Homekit did not know the TV was turned on or off, so it did not turn on/off the input boolean I set up in homekit automation. am I missing something. If I turn on/off the TV with the standard IR remote of the TV does it not tell homekit that it is off/on?
Cory, this looks perfect! Would you be willing to share your scripts and switches? This looks like how I’d like to set up mine, but I’m struggling in some areas and think that seeing how you set up your scripts and switches might show me what I’m doing wrong.
media_player.tv:
friendly_name: TV
source_list:
- Select Input
- tiniBooty
- Apple TV
- Xbox One
- Nintendo Switch
- PS4
media_player.yaml (I plugged in some, but not all, of the source scripts — but didn’t think it’d matter as a test, and don’t get the impression it’s affecting the error)
tv_input:
options:
- Select Input
- tiniBooty
- Apple TV
- Xbox One
- Nintendo Switch
- PS4
In messing with it, I didn’t try the input.boolean automations yet. But as the error seems to be that “media_player.tv” isn’t found, I don’t get the impression that’s affecting it. Especially as there’s no reference of “media_player” in that.
@chrisbrummel, I’m just getting into this myself so I’m no expert, but I’ve gotten my media_player to successfully work so I thought I could attempt to help. One thing you might try is to have your config display the source_list in brackets, like so:
media_player.tv:
friendly_name: TV
source_list: [Select Input,tiniBooty,Apple TV,Xbox One,Nintendo Switch,PS4]
@Tangston311 Thanks for the tip. I pasted your styling, but still no luck.
@Corey_Maxim I hadn’t had my media player settings separated out into its own file, but I tried that and got the same error. Invalid config for [media_player]: required key not provided @ data['platform']. Got None.
The text in media_player.yaml looks the same as what @Tangston311 pasted above