Advertisement
xangin

show how many automations

May 25th, 2023 (edited)
1,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.86 KB | None | 0 0
  1. # 功用: 統計共有多少自動化及啟用的自動化
  2. # 用法: 1. 將以下code放在configuration.yaml內
  3. #       2. 至開發工具>YAML>檢查設定內容>沒有錯誤訊息>下方>點模板實體
  4. #       3. 即可在開發工具>狀態找到新增的template sensor
  5. # 補充: 把states.automation改為states.binary_sensor, sensor, script, switch等即可統計有多少數量
  6.  
  7. template: #已有template要記得刪除這行,不能重複
  8.   - sensor:
  9.       #自動化總數
  10.       - name: "total_automations"
  11.         unique_id: total_automations
  12.         icon: mdi:robot
  13.         state: >
  14.          {{ states.automation | count }}
  15.       #啟用的自動化數量
  16.       - name: "automations_on"
  17.         unique_id: automations_on
  18.         icon: mdi:robot
  19.         state: >
  20.          {{ states.automation | selectattr('state','eq','on') | list | count }}    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement