Advertisement
xangin

HA automation package notify

Feb 22nd, 2024
1,252
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.66 KB | None | 0 0
  1. - id: package_track_notify
  2.   alias: package_track_notify
  3.   description: 通知-社區包裹通知
  4.   mode: single
  5.   trigger:
  6.     - platform: state
  7.       entity_id: sensor.my_package_tracker      
  8.       attribute: unclaimed_packages_count
  9.   condition: []
  10.   action:
  11.     - variables:
  12.         person: >
  13.          {% if state_attr("sensor.my_package_tracker","p_name") == 'AAA' %}
  14.             AA
  15.           {% elif state_attr("sensor.my_package_tracker","p_name") == 'BBB' %}
  16.             BB
  17.           {% elif state_attr("sensor.my_package_tracker","p_name") == 'CCC' %}
  18.             CC
  19.           {% elif state_attr("sensor.my_package_tracker","p_name") == 'DDD' %}
  20.             DD
  21.           {% else %}
  22.             {{ state_attr("sensor.my_package_tracker","p_name") }}
  23.           {% endif %}
  24.  
  25.     - choose:
  26.         - conditions:
  27.             - condition: state
  28.               entity_id: sensor.my_package_tracker
  29.               state: '未領取'
  30.           sequence:
  31.             - service: notify.line_notify
  32.               data:
  33.                 message: >
  34.                  {{ person }}的{{state_attr("sensor.my_package_tracker","postal_typeText")}}來囉!
  35.                 data:
  36.                   url: >
  37.                    {{ state_attr("sensor.my_package_tracker","postal_img") }}
  38.                    
  39.         - conditions:
  40.             - condition: state
  41.               entity_id: sensor.my_package_tracker
  42.               state: '已取件'
  43.           sequence:
  44.             - service: notify.line_notify
  45.               data:
  46.                 message: >
  47.                  {{ person }}的{{ state_attr("sensor.my_package_tracker","postal_typeText") }}已領取
  48.  
  49.  
  50.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement