Advertisement
xangin

HA earthquake alert automation2

May 24th, 2024 (edited)
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.20 KB | None | 0 0
  1. - id: '1714012563709'
  2.   alias: earthquake_automation2
  3.   description: 地震預報通知2
  4.   mode: single
  5.   trigger:
  6.   - platform: webhook
  7.     allowed_methods:
  8.    - POST
  9.     local_only: true
  10.     webhook_id: trigger_ea_cmd
  11.   condition: []
  12.   action:
  13.   - variables:
  14.       lv: '{{ trigger.json.level[:1] | int }}'
  15.       time: '{{ trigger.json.seconds }}'
  16.   - if:
  17.     - condition: template
  18.       value_template: '{{ lv >2 }}'
  19.       alias: 地震是否大於2
  20.     then:
  21.     - alias: 打開電燈
  22.       service: switch.turn_on
  23.       data: {}
  24.       target:
  25.         entity_id:
  26.        - switch.guest_room
  27.         - switch.living_room
  28.     - alias: 打開Google音箱
  29.       service: media_player.turn_on
  30.       data: {}
  31.       target:
  32.         entity_id:
  33.        - media_player.guest_room_mini
  34.     - alias: 根據震度設定Google音箱音量
  35.       service: media_player.volume_set
  36.       data:
  37.         entity_id:
  38.        - media_player.guest_room_mini
  39.         volume_level: '{{ 0.1*lv }}'
  40.     - alias: Google音箱播放訊息
  41.       service: tts.edge_tts_say
  42.       data:
  43.         entity_id:
  44.        - media_player.guest_room_mini
  45.         message: 警告!{{ lv }}級地震將在{{ time }}秒後抵達
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement