Z-wave battery report

I am trying to create a weekly report where all z-wave devices battery attribute is sent in an email. Unfortunately not working.

    - alias: Batt_report
  hide_entity: True
  trigger:
    - platform: template
      value_template: >
        {% for zwave in states.zwave if zwave.attributes.battery_level %}
          {%- if zwave.attributes.battery_level | int < 101 -%}
            {{true}}
          {%- endif -%}
        {%- endfor -%}
  condition:
    condition: time
    weekday:
      - wed
    at: '18:15:00'
  action:
    - service: notify.gmail
      data:
        Title: Weekly Z-wave battery report
        message: >
          {{ trigger.to_state.attributes.friendly_name }} has battery level: {{trigger.to_state.attributes.battery_level}}

The fault from configuration check:
Invalid config for [automation]: extra keys not allowed @ data[‘condition’][0][‘conditions’][1][‘at’]. Got None
not a valid value for dictionary value @ data[‘condition’][0][‘conditions’][1][‘condition’]. Got None
required key not provided @ data[‘condition’][0][‘conditions’][1][‘entity_id’]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 247). Please check the docs at https://home-assistant.io/components/automation/

Any suggestions?

It’s telling you that the at in your condition is not valid.

I think you should have a time pattern trigger every wednesday at 18:15, since every battery is going to be less than 101%.

Using the example from the template tool, a rough action example would be:

{% for zwave in states.zwave if zwave.attributes.battery_level %}
{%- if loop.first %}The {% elif loop.last %} and the {% else %}, the {% endif -%}
  {{ zwave.name | lower }} is {{zwave.attributes.battery_level}}%
{%- endfor %}.

Try it in your template page (looks like a page with ‘< >’ on your Home Assistant page) to see what you get.

Thank you, it seems fair.

So this is the result and I will get a small report every week about the battery level.

#Create battery report once per week
- alias: Batt_report
  hide_entity: True
  trigger:
    - platform: time
      at: '18:15:00'
  condition:
    condition: time
    weekday:
      - sat

  action:
    - service: notify.gmail
      data:
        title: "Weekly battery report"
      data_template:
        message: >
          {% for zwave in states.zwave if zwave.attributes.battery_level %}
          {%- if loop.first %}The {% elif loop.last %} and the {% else %}, the {% endif -%}
          {{ zwave.name | lower }} is {{zwave.attributes.battery_level}}%
          {%- endfor %}