impeham
(Liran)
November 11, 2019, 7:27pm
1
i need some help to set the following up - the purpose to have media_player.media_play or rest_command.kodi_secondary call according to the specified condition, but these services have 2 different set of data parameters - one receives “entity_id” and the other “body”
script:
kodi_sec_replay:
alias: Kodi Secondary Replay
sequence:
- service_template: >
{% if (states('input_select.kodi_play_file') == "N/A") %}
media_player.media_play
{% else %}
rest_command.kodi_secondary
{% endif %}
data_template: >
{% if (states('input_select.kodi_play_file') == "N/A") %}
entity_id: media_player.kodi_secondary
{% else %}
{"jsonrpc":"2.0","method":"Player.Open","id":1,"params":[{"playlistid":0,"position":0}]}'}
{% endif %}
Automations don’t work like that.
You can write two separate scripts (plus a third master script) with conditions to halt execution of kodi_play_file isn’t in the right state.
kodi_sec_replay_na:
sequence:
- condition: template
value_template: "{{ is_state('input_select.kodi_play_file', 'N/A') }}"
- service: media_player.media_play
kodi_sec_replay_not_na:
sequence:
- condition: template
value_template: "{{ not is_state('input_select.kodi_play_file', 'N/A') }}"
- service: rest_command.kodi_secondary
kodi_sec_replay:
sequence:
- service: script.kodi_sec_replay_na
- service: script.kodi_sec_replay_not_na
Or, easier, you can write a python_script to handle it using more conventional logic.
Or, easier still, install AppDaemon to handle this sort of thing and more.
impeham
(Liran)
November 11, 2019, 7:39pm
3
sorry i missed the 1st line - it’s a script
Yeah. I guessed that. You’ll need to use 3 separate scripts to do this (as I provided an example of). Or a python_script. Or AppDaemon.
When I said “automations don’t work like that”, I meant the “action” part of an automation, which works identical to a script.
1 Like
impeham
(Liran)
November 11, 2019, 7:41pm
5
thanks - will go the python script i think