- alias: Remove Completed from Einkaufsliste
  id: "1721984657081"
  description: ""
  trigger:
    - trigger: time_pattern
      minutes: "30"
  condition: []
  action:
    - variables:
        lists: |-
          {%- set lists = states.todo | selectattr('entity_id')| map(attribute='entity_id')| list -%} 
          {{ lists }}
    - repeat:
        sequence:
          - action: todo.remove_completed_items
            metadata: {}
            data: {}
            target:
              entity_id: "{{ repeat.item }}"
        for_each: "{{ lists }}"
  mode: single
- alias: Update forecast information
  id: "1751495803400"
  description: ""
  triggers:
    - trigger: time_pattern
      hours: /1
  conditions: []
  actions:
    - action: weather.get_forecasts
      metadata: {}
      data:
        type: hourly
      target:
        entity_id: weather.forecast_home
      response_variable: hourly
    - action: weather.get_forecasts
      metadata: {}
      data:
        type: daily
      target:
        entity_id: weather.forecast_home
      response_variable: daily
    - action: persistent_notification.create
      metadata: {}
      data:
        message: "{{daily['weather.forecast_home']}}"
      enabled: false
    - action: variable.update_sensor
      metadata: {}
      data:
        replace_attributes: true
        attributes:
          "{\n  \"timestamp\": [\n    {% for i in range(24) %}\n      \"{{
          hourly['weather.forecast_home'].forecast[i].datetime }}\"\n      {{ \",\"
          if not loop.last }}\n    {% endfor %}\n  ],\n  \"temperature\": [\n    {%
          for i in range(24) %}\n      {{ hourly['weather.forecast_home'].forecast[i].temperature
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"humidity\":
          [\n    {% for i in range(24) %}\n      {{ hourly['weather.forecast_home'].forecast[i].humidity
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"wind_speed\":
          [\n    {% for i in range(24) %}\n      {{ hourly['weather.forecast_home'].forecast[i].wind_speed
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"uv_index\":
          [\n    {% for i in range(24) %}\n      {{ hourly['weather.forecast_home'].forecast[i].uv_index
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"cloud_coverage\":
          [\n    {% for i in range(24) %}\n      {{ hourly['weather.forecast_home'].forecast[i].cloud_coverage
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"precipitation\":
          [\n    {% for i in range(24) %}\n      {{ hourly['weather.forecast_home'].forecast[i].precipitation
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"condition\":
          [\n    {% for i in range(24) %}\n      \"{{ hourly['weather.forecast_home'].forecast[i].condition
          }}\"\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ]\n}\n"
      target:
        entity_id: sensor.forecast_hourly
    - action: variable.update_sensor
      metadata: {}
      data:
        replace_attributes: true
        attributes:
          "{\n  \"timestamp\": [\n    {% for i in range(5) %}\n      \"{{
          daily['weather.forecast_home'].forecast[i].datetime }}\"\n      {{ \",\" if
          not loop.last }}\n    {% endfor %}\n  ],\n  \"temperature\": [\n    {% for
          i in range(5) %}\n      {{ daily['weather.forecast_home'].forecast[i].temperature
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"humidity\":
          [\n    {% for i in range(5) %}\n      {{ daily['weather.forecast_home'].forecast[i].humidity
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"wind_speed\":
          [\n    {% for i in range(5) %}\n      {{ daily['weather.forecast_home'].forecast[i].wind_speed
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"templow\":
          [\n    {% for i in range(5) %}\n      {{ daily['weather.forecast_home'].forecast[i].templow
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"precipitation\":
          [\n    {% for i in range(5) %}\n      {{ daily['weather.forecast_home'].forecast[i].precipitation
          }}\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ],\n  \"condition\":
          [\n    {% for i in range(5) %}\n      \"{{ daily['weather.forecast_home'].forecast[i].condition
          }}\"\n      {{ \",\" if not loop.last }}\n    {% endfor %}\n  ]\n}\n"
      target:
        entity_id: sensor.forecast_daily
  mode: single
- alias: Auto Remove Delivered Packages
  id: "1745310026096"
  description: ""
  triggers:
    - trigger: time
      at: 03:55:00
      enabled: false
  conditions:
    - condition: template
      value_template:
        "{{states.sensor['17track_delivered'].attributes.packages |
        length >0}}"
  actions:
    - repeat:
        sequence:
          - variables:
              tracking_no:
                "{{states.sensor['17track_delivered'].attributes.packages[0].tracking_number}}

                "
          - action: seventeentrack.archive_package
            metadata: {}
            data:
              config_entry_id: 01JA545FB4S1WQCDDC2RZ5W63V
              package_tracking_number: "{{ tracking_no }}"
          - delay:
              hours: 0
              minutes: 35
              seconds: 15
              milliseconds: 0
        while:
          - condition: template
            value_template:
              "{{states.sensor['17track_delivered'].attributes.packages
              | length >0}}"
  mode: single
