HI hi goodmorning to you all!
Once again im looking for help for the finishing touches on my home assistant.
I have this package:
############################################
## Pioneer VSX-922 ##
############################################
###### MEDIA PLAYER --------------------------------------------
media_player:
- platform: pioneer
host: 10.3.1.4
name: VSX-922
###### SENSORS -------------------------------------------------
sensor:
- platform: template
sensors:
vsx992:
friendly_name: Pioneer VSX-922
value_template: "{% if is_state('device_tracker.vsx922', 'home') %}Connected{% else %}Offline{% endif %}"
icon_template: "{% if is_state('device_tracker.vsx922', 'home') %} mdi:surround-sound-5-1{% else %}mdi:lan-disconnect{% endif %}"
- platform: template
sensors:
vsx922_volume:
friendly_name: "VSX922 Volume"
value_template: "{{ states.media_player.vsx922.attributes.volume_level }}"
- platform: template
sensors:
vsx922_source:
friendly_name: "VSX922 Source"
value_template: "{{ states.media_player.vsx922.attributes.source }}"
###### INPUT SELECT -------------------------------------------
input_select:
vsx922_source:
name: 'Source:'
options:
- KODI
- TV
- ZIGGO
- Chromecast
icon: mdi:source
###### INPUT NUMBER----------------------------------------------
input_number:
vsx922_volume:
name: Volume
icon: mdi:volume-high
initial: 0
min: 0
max: 100
step: 1
###### SCRIPTS -------------------------------------------------
script:
vsx922_source:
alias: "Set Input"
sequence:
- service: media_player.select_source
data_template:
entity_id: media_player.vsx922
source: >
{% if is_state("input_select.vsx922_source", "KODI") %} KODI
{% elif is_state("input_select.vsx922_source", "TV") %} TV
{% elif is_state("input_select.vsx922_source", "ZIGGO") %} ZIGGO
{% elif is_state("input_select.vsx922_source", "Chromecast") %} Chromecast
{% endif %}
###### AUTOMATIONS -------------------------------------------------
automation:
- alias: 'Pioneer VSX922 Volume Set'
trigger:
platform: state
entity_id: input_number.vsx922_volume
action:
service: media_player.volume_set
data_template:
entity_id: media_player.vsx922
volume_level: '{{ states.input_number.vsx922_volume.state | int / 100 }}'
- alias: 'Pioneer VSX922 Volume (Sync)'
trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: sensor.vsx922_volume
action:
- delay:
seconds: 5
- service: input_number.set_value
data_template:
entity_id: input_number.vsx922_volume
value: '{{ states.sensor.vsx922_volume.state | float | round(2) * 100 }}'
- alias: 'Pioneer VSX922 Source (Sync)'
trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: sensor.vsx922_source
action:
service: input_select.select_option
entity_id: input_select.vsx922_source
data_template:
option: '{{ states.sensor.vsx922_source.state }}'
Almost everything works, the volume can be set from lovelace and syncs back when i change the volume on the remote, also when i change the input on my remote the - entity: input_select.vsx922_source in ui-lovelace shows the correct source.
But when i select the source from the input_select, nothing happens, does anyone can give me recommendations on what im missing here? Thank you
If im a bit unclear an need to make a video let me know
You don’t have an automation in that package that is triggered by an input_select.
I tought that was the issues.
i tried:
- alias: 'Pioneer VSX922 Source Set'
trigger:
platform: state
entity_id: input_select.vsx922_source
action:
service: media_player.select_source
data_template:
entity_id: media_player.vsx922
input_select: '{{ states.input_select.vsx922_source }}'
but i cant get it to work, i must have something wrong but im not sure what part
petro
(Petro)
September 30, 2018, 1:14pm
4
You were close in your automation. Just needed to add .state to your states.input_select.vsx922_source template. Also, you should add protection for states that aren’t selected and for when the media player is off.
- alias: 'Pioneer VSX922 Source Set'
trigger:
platform: state
entity_id: input_select.vsx922_source
condition:
- condition: template
value_template: >
{{ is_state('media_player.vsx922','on') and trigger.to_state.state in state_attr('media_player.vsx922','source_list') }}
action:
service: media_player.select_source
data_template:
entity_id: media_player.vsx922
source: '{{ states.input_select.vsx922_source.state }}'
or
- alias: 'Pioneer VSX922 Source Set'
trigger:
platform: state
entity_id: input_select.vsx922_source
condition:
- condition: template
value_template: >
{{ is_state('media_player.vsx922','on') and trigger.to_state.state in state_attr('media_player.vsx922','source_list') }}
action:
service: media_player.select_source
data_template:
entity_id: media_player.vsx922
source: "{{ states('input_select.vsx922_source') }}"
or
- alias: 'Pioneer VSX922 Source Set'
trigger:
platform: state
entity_id: input_select.vsx922_source
condition:
- condition: template
value_template: >
{{ is_state('media_player.vsx922','on') and trigger.to_state.state in state_attr('media_player.vsx922','source_list') }}
action:
service: media_player.select_source
data_template:
entity_id: media_player.vsx922
source: '{{ trigger.to_state.state }}'
petro:
alias: ‘Pioneer VSX922 Source Set’ trigger: platform: state entity_id: input_select.vsx922_source condition: - condition: template value_template: > {{ is_state(‘media_player.vsx922’,‘on’) and trigger.to_state.state in state_attr(‘media_player.vsx922’,‘source_list’) }} action: service: media_player.select_source data_template: entity_id: media_player.vsx922 input_select: ‘{{ trigger.to_state.state }}’
Thank you for youre time and script, i paste it in, tried all 3 offcourse, but non of them are working.
Cee
(Si Gray)
September 30, 2018, 6:03pm
6
So I have a VSX-930, and I had the same problems with you in setting the inputs from HA. And what solved it for me, was I had custom renamed the inputs, which is seems you have done as well, and for some reason, setting them back to the default name’s and then it started to work. Think something is up with the component and custom input names, but unfortunately its beyond me to work out what it is, so I just set everything back to default and it all works from there.
do you have a github so i can check how your code looks like? also did you renamed the inputs on the receiver or did you have to set them to default on teh receiver aswell? that would kinda skc.
And btw the TV in my input_select is a default name, which is also still tv on my receiver.
Cee
(Si Gray)
September 30, 2018, 6:35pm
9
I had renamed them on the iPad app, and then just went back in and renamed them back to what it said they should have been on that.
I dont have a github, but this a some of the script samples I use, I dont use any form of selection box or such like through HA, I just use HA to make my life easier, with the idea of not having to use the interface for anything.
stream_living_room_cast:
alias: Start streaming Living Room
sequence:
- data:
entity_id: media_player.pioneer_amp
service: media_player.turn_on
- delay: 00:00:08
- data:
entity_id: media_player.pioneer_amp
source: CD
service: media_player.select_source
tv_turn_on_kodi:
alias: Tv Amp On Kodi On
sequence:
- data:
entity_id: media_player.pioneer_amp
service: media_player.turn_on
- data:
entity_id: media_player.kodi
service: media_player.turn_on
- delay: 00:00:08
- data:
entity_id: media_player.pioneer_amp
source: DVD
service: media_player.select_source
movie_announcement:
alias: Movie Announcement
sequence:
- data:
entity_id: media_player.living_room_speaker
service: media_player.turn_on
- data:
entity_id: media_player.kodi
service: media_player.media_pause
- data:
entity_id: media_player.pioneer_amp
source: CD
service: media_player.select_source
- data:
entity_id: media_player.pioneer_amp
volume_level: 0.55
service: media_player.volume_set
- delay: 00:00:18
- data:
entity_id: media_player.pioneer_amp
volume_level: 0.4
service: media_player.volume_set
- data:
entity_id: media_player.pioneer_amp
source: DVD
service: media_player.select_source
- data:
entity_id: media_player.kodi
service: media_player.media_play
Hopefully maybe that will help you out, but maybe not, shout if there is anything else I might be able to help with.
petro
(Petro)
September 30, 2018, 7:44pm
10
What are the errors in the log? Do does your input select names match the source list EXACTLY. That means spelling and Capital letters. I.E. foo does not equal Foo
Hi, yes the names are correctly, no extra spaces or so. Im not very sure what the three option you gave me are, but im using the last one in the automation
{% if is_state("input_select.vsx922_source", "KODI") %} KODI
{% elif is_state("input_select.vsx922_source", "TV") %} TV
{% elif is_state("input_select.vsx922_source", "ZIGGO") %} ZIGGO
{% elif is_state("input_select.vsx922_source", "Chromecast") %} Chromecast
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=input_select, service=select_option, service_data=option=Chromecast, entity_id=input_select.vsx922_source, service_call_id=a3244706d9d34682b53e5456161113a2>
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=input_select.vsx922_source, old_state=<state input_select.vsx922_source=TV; options=['KODI', 'TV', 'ZIGGO', 'Chromecast'], friendly_name=Source:, icon=mdi:source @ 2018-10-01T17:49:02.365014+02:00>, new_state=<state input_select.vsx922_source=Chromecast; options=['KODI', 'TV', 'ZIGGO', 'Chromecast'], friendly_name=Source:, icon=mdi:source @ 2018-10-01T17:49:53.073740+02:00>>
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.components.automation] Executing Pioneer VSX922 Source Set
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.core] Bus:Handling <Event logbook_entry[L]: name=Pioneer VSX922 Source Set, message=has been triggered, domain=automation, entity_id=automation.pioneer_vsx922_source_set>
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.helpers.script] Script Pioneer VSX922 Source Set: Running script
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.helpers.script] Script Pioneer VSX922 Source Set: Executing step call service
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=select_source, service_data=entity_id=media_player.vsx922, input_select=Chromecast, service_call_id=1e2fa52a76104f3981f5ff25fcaaeda1>
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=a3244706d9d34682b53e5456161113a2>
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 ERROR (MainThread) [homeassistant.core] Invalid service data for media_player.select_source: extra keys not allowed @ data['input_select']. Got 'Chromecast'
okt 01 17:49:53 HTPC-01 hass[30642]: required key not provided @ data['source']. Got None
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1e2fa52a76104f3981f5ff25fcaaeda1>
okt 01 17:49:53 HTPC-01 hass[30642]: 2018-10-01 17:49:53 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.pioneer_vsx922_source_set, old_state=<state automation.pioneer_vsx922_source_set=on; last_triggered=2018-10-01T17:49:02.374969+02:00, friendly_name=Pioneer VSX922 Source Set @ 2018-10-01T17:40:56.053691+02:00>, new_state=<state automation.pioneer_vsx922_source_set=on; last_triggered=2018-10-01T17:49:53.083583+02:00, friendly_name=Pioneer VSX922 Source Set @ 2018-10-01T17:40:56.053691+02:00>>
petro
(Petro)
October 1, 2018, 3:52pm
12
Bah, that’s my bad, I edited the templates I wrote. Copy and try them again. I used the wrong attribute name, now using the attribute name ‘source’.
1 Like
it works! finally! thank you so much, which on should i use 1 2 or 3 im reading the code but im not totally understand the differents
just want to let you know that petro fixed it for me. Maybe it applies to youre setup aswell
1 Like
petro
(Petro)
October 1, 2018, 4:10pm
15
They all work, depends on what you want to do.
method 1 and 2 are hard coded. Meaning that they are locked to the input_select placed inside the data_template.source. Method 1 uses the states object as an object. This means that during initialization, you could get some errors in the logs. Method 2 uses the states() method. It could return ‘unknown’ if the media_player doesn’t respond, but it shouldn’t error in the logs. Method 3 is agnostic in regards to the trigger method. It would work if you decided to add another input_select.
Your best bet would be to go with method 2 if you never plan on making another dropdown box with selections that point to this media player.
2 Likes