Mail and Packages: Custom component for UPS, FEDEX, and USPS

post your config

I was basically just copying and pasting from the wiki:

    - platform: template
      sensors:
        mail_deliveries_message:
          friendly_name: "Deliveries Summary"
          value_template: > 
            {# Deliveries Sentence #}
              {% macro deliveries_sentence() -%}
                    {%- if states("sensor.mail_usps_mail")|int == 0 -%}
                      No
                    {%- else -%}
                      {{states("sensor.mail_usps_mail")|int}}
                    {%- endif -%}
                  {{' '}} 
                    {%- if states("sensor.mail_usps_mail")|int <= 1 -%}
                      pieces of mail
                    {%- else -%}
                      pieces of mail
                    {%- endif -%}
                  {{' '}}will be delivered.{{' '}} 
                    {%- if states("sensor.mail_usps_delivering")|int == 0 -%}
                      No
                    {%- else -%}
                      {{states("sensor.mail_usps_delivering")|int}}
                    {%- endif -%}
                  {{' '}} 
                    {%- if states("sensor.mail_usps_delivering")|int == 1 -%}
                      USPS package is
                    {%- else -%}
                      USPS packages are
                    {%- endif -%}
                  {{' '}}in transit.{{' '}}
                    {%- if states("sensor.mail_fedex_delivering")|int == 0 -%}
                      No
                    {%- else -%}
                      {{states("sensor.mail_fedex_delivering")|int}}
                    {%- endif -%}
                  {{' '}} 
                    {%- if states("sensor.mail_fedex_delivering")|int == 1 -%}
                      FedEx package is
                    {%- else -%}
                      Fedex packages are
                    {%- endif -%}
                  {{' '}}in transit.{{' '}}
                  {%- if states("sensor.mail_ups_delivering")|int == 0 -%}
                      No
                    {%- else -%}
                      {{states("sensor.mail_ups_delivering")|int}}
                    {%- endif -%}
                  {{' '}} 
                    {%- if states("sensor.mail_ups_delivering")|int == 1 -%}
                      UPS package is
                    {%- else -%}
                      UPS packages are
                    {%- endif -%}
                  {{' '}}in transit.{{' '}}
                  {%- if states("sensor.mail_amazon_packages")|int == 0 -%}
                      No
                    {%- else -%}
                      {{states("sensor.mail_amazon_packages")|int}}
                    {%- endif -%}
                  {{' '}} 
                    {%- if states("sensor.mail_amazon_packages")|int == 1 -%}
                      Amazon package is
                    {%- else -%}
                      Amazon packages are
                    {%- endif -%}
                  {{' '}}in transit.{{' '}}
              {%- endmacro %}
            {{deliveries_sentence()}}

it comes in without any indents on the ā€œ- platformā€ part. I get the error above. If I highlight the entire thing, then hit ā€œtabā€, it indents everything accordingly, but it still gives the error above.

This sits below other sensors that Iā€™ve defined.

You have this under your sensors: setup then right?

Itā€™s under the sensor: setup (without the ā€œsā€)

Youā€™d need to put it under any other location youā€™ve placed the template sensors in your file.

Ah, that was it - thank you!

1 Like

I tried searching the thread, but wasnt able to find an answer, not to mention it being hard with almost 900 posts, but Iā€™m having trouble getting the image to display on the lovelace card, running HassOS 5.4. Any potential solutions? Iā€™ve tried several different image paths and reset browser cache.

Your mail GIF location likely needs to match the location of where itā€™s set to in the Integration.

Awesome, got it working!

Iā€™ve noticed a lot of errors on startup related to sensors not yet loaded. I saw it mentioned before but the only solution seemed to be to just ignore them? Is that still the case? Thanks in advance!

Those are warnings not errors, you can ignore them, but for mail_and_packages my sensors load in about 8.4 seconds thatā€™s decent for something logging into email and doing a search :stuck_out_tongue:

1 Like

Ugh, My USPS digest email just came from a new address [email protected], because it didnā€™t match my filters. Why canā€™t they just leave well-enough alone?

Yes I just pushed a PR to fix that.

Our procedures were reversed. I posted here, then I saw your GH issue/PR

1 Like

Answers why my USPS stopped working. Assume itā€™s different as never compared. Itā€™s been a hot minute since Iā€™ve had to change anything on this. Where do you change the email addresses it looks for?

NOTE: Found it in the const.py. Now to know if itā€™s just that address or the prior one will come on the weekdays or something weird like that. Guessing you canā€™t comma separate values.

Thanks.

JR

You donā€™t have to change anything, the latest version fixes it :wink:

1 Like

After updating to 118.0 it appears that the Mail and Packages module is now using Time (UTC) and longer using local time as the mail_updated sensor is now 5 hours ahead though my other time sensors are showing the correct time. Is there a simple thing I can do to correct this?

Also, it is no longer showing correct mail status showing no mail even though my USPS email shows there will be mail today.

Looks like an issue in HA, please refer to the 0.118 blog thread. Thereā€™s been quite a few posts regarding it.

If you are running just the docker container try adding:

      - /etc/localtime:/etc/localtime:ro

to you devices mappings, this should import your local time and timezone into the container.

Full example:

    volumes:
      - /home/docker/home-assistant:/config
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/localtime:/etc/localtime:ro

Perhaps itā€™s discussed in this thread and missed it but are we supposed to remove our entity_id values and be done with it for our templates? I am getting an error/warning in my logs and imagine from what I read Iā€™m supposed to remove the whole entity_id and the indented items from my sensor like below?

image

Thanks.

JR

Yes you can remove them, theyā€™re no longer required to be there.

Just updated with the latest beta I believe and all my entities are gone.

Noticed a lot of the jobs and stuff are now _2 and all the entnties seem lilke they may have all be replaced with _2 variants. What happened?