Advertisement
JLindvig

vlookup

Oct 4th, 2019
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.87 KB | None | 0 0
  1. automation:
  2.   - alias: "Find Movie URL"
  3.     trigger:
  4.       - platform: state
  5.         # Den input_select som indeholder søgeværdien ( filmen )
  6.         entity_id: input_select.movie
  7.     action:
  8.       - service: script.vlookup
  9.  
  10.  
  11. script:
  12.   vlookup:
  13.     alias: "VLOOKUP"
  14.     sequence:
  15.       - service: input_select.select_option
  16.         data_template:
  17.          # Den input_select som der skal returneres fra ( URL )
  18.           entity_id: input_select.movie_url
  19.           option: >-
  20.             # Gå alle filmene igennem
  21.             {% for item in states.input_select.movie.attributes.options %}
  22.               {% if item == states('input_select.movie') %}
  23.                 # Returner URL fra samme index som filmens navn ( loop.index0 )
  24.                 {{ states.input_select.movie_url.attributes.options[loop.index0] }}
  25.               {% endif %}
  26.             {%- endfor %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement