Advertisement
xangin

get_text_to_cmd

Aug 20th, 2023
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.78 KB | None | 0 0
  1. automation:
  2.   - id: get_text_to_cmd
  3.     alias: get_text_to_cmd
  4.     description: "擷取文字轉成指令"  
  5.     trigger:
  6.       - platform: state
  7.         entity_id: input_text.some_sentence
  8.         from: " "
  9.         not_to: " "
  10.     condition: []
  11.     action:
  12.       - variables:
  13.           line_cmd: >
  14.           {% if "小愛同學" in states("input_text.some_sentence") -%}
  15.              {{ states("input_text.some_sentence")[4:] }}
  16.            {%- endif %}      
  17.  
  18.       - choose:
  19.           - alias: "關陽台燈"
  20.             conditions:
  21.               - condition: template
  22.                 value_template: "{{ line_cmd == '關陽台燈' }}"
  23.             sequence:
  24.               - service: switch.turn_off
  25.                 target:
  26.                   entity_id: switch.balcony_light
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement