template:
  - sensor:
      - name: "Internet Download Traffic"
        unique_id: internet_downtraffic
        unit_of_measurement: "kB/s"
        state_class: measurement
        availability: "{{ has_value('sensor.edgerouter_wan_download_rate') }}"
        state: "{{ states('sensor.edgerouter_wan_download_rate') | float(0) }}"

      - name: "Internet Upload Traffic"
        unique_id: internet_uptraffic
        unit_of_measurement: "kB/s"
        state_class: measurement
        availability: "{{ has_value('sensor.edgerouter_wan_upload_rate') }}"
        state: "{{ states('sensor.edgerouter_wan_upload_rate') | float(0) }}"

      - name: "Internet Total Traffic"
        unique_id: internet_totaltraffic
        unit_of_measurement: "kB/s"
        state_class: measurement
        availability: >-
          {{
            has_value('sensor.edgerouter_wan_download_rate')
            and has_value('sensor.edgerouter_wan_upload_rate')
          }}
        state: >-
          {{
            (states('sensor.edgerouter_wan_download_rate') | float(0))
            + (states('sensor.edgerouter_wan_upload_rate') | float(0))
          }}
