jcallaghan / home-assistant-config

My Home Assistant configuration & documentation.
https://www.jcallaghan.com/
MIT License
173 stars 8 forks source link

Shopping list integration > multiple list integration #291

Open jcallaghan opened 2 years ago

jcallaghan commented 2 years ago

Quest to see if can make a multiple-list integration similar to the shopping list integration and shopping list card.

image

alphasixtyfive commented 2 years ago

Built-in shopping list integration is simply reading from and writing to a json file /config/.shopping_list.json. I have recently created a command_line sensor which reads that file every 5 seconds.

- platform: command_line
  name: Shopping list
  command: "jq -r '{complete: [.[] | select(.complete==true)], incomplete: [.[] | select(.complete==false)]}' /config/.shopping_list.json"
  value_template: "{{ value_json.incomplete | length }}"
  json_attributes:
    - complete
    - incomplete
  scan_interval: 5

I'm currently using it to sync with Yandex Station and Telegram bot.