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

thanks! can you confirm what you mean by hamlet? (apologies still learning over here)

Typoā€¦ the YAML

Gotcha. I was using the post 0.115 exampleā€¦

You are seeing the final image file in the folder?
Both the amazon delivery and the MP4 card are in the folder. Fixed the amazon card issue (my issue)

Which sensor are you using to supply the image path and where are you expecting the image to show?
I was using a picture card to show the Amazon image and the mail and package card to show the mail. Iā€™ll double check the docs and see what changed and see if I can get both displaying again.

I was able to fix the amazon image, Somehow I had the wrong path. I must have copied the wrong code when I was fixing something else on my lovelace display.
I was unable to get the image for the USPS. I believe I broke this when the name changed
My code:

  -
    type: 'custom:mail-and-packages-card'
    name: Mail Summary
    updated: sensor.mail_updated
    details: true
    image: true
    deliveries_message: sensor.mail_deliveries_message
    packages_delivered: sensor.mail_packages_delivered
    packages_in_transit: sensor.mail_packages_in_transit
    fedex_packages: sensor.mail_fedex_delivering
    ups_packages: sensor.mail_ups_packages
    usps_packages: sensor.mail_usps_packages
    amazon_packages: sensor.mail_amazon_packages
    gif_sensor: sensor.mail_image_url
    camera_entity: camera.mail_usps
    camera: false

I was confused with the wiki directions from the custom card as the file name changed.

https://github.com/moralmunky/Home-Assistant-Mail-And-Packages-Custom-Card

Thanks.

What is the recommended automation to update the camera image now? Iā€™m currently using

alias: Update USPS Mail Camera
trigger:
  - platform: state
    entity_id: sensor.mail_usps_mail
    attribute: image
action:
  - service: local_file.update_file_path
    data:
      file_path: |
        {{ states('sensor.mail_image_system_path') }}
    entity_id: camera.mail_usps
mode: single
variables:
  path: >-
    {% if state_attr("sensor.mail_usps_mail","image") == None  %}

    /config/custom_components/mail_and_packages/mail_none.gif

    {% else %}

    /config/images/mail_and_packages/{{state_attr("sensor.mail_usps_mail","image")}}

    {% endif %}

But, Iā€™m noticing that since the image only changes once a day, if I restart HA, then the camera defaults back to the mail_none image until the next day when the gif is updated. Should I add a second trigger for like ā€œha startedā€ or something?

For the last official version please see the wiki

For the recent beta documentation hasnā€™t been developed until the official release. It would be similar to what is in the WIKI now except referring the sensor for the full system path.

Something like this (I donā€™t use this and havenā€™t tested it)
The trigger could be sensor.mail_image_system_path or left as sensor.mail_usps_mail

- alias: "Update USPS Mail Camera"
  trigger:
    - platform: state
      entity_id: sensor.mail_usps_mail
  action:
    - service: local_file.update_file_path
      data_template:
        entity_id: camera.mail_usps
        file_path: {{ states('sensor.mail_image_system_path') }}

Could be that your sensor: line 73 needs the two space indent removed.

The custom card you are using looks old. Unavailable sensors are usually fixed by going through the options for the integrations in the integrations section. You would need to enable debugging and check the logs to see if there are any errors to troubleshoot.

Yes, iā€™m using the beta. If you just use sensor.mail_image_system_path as the trigger, youā€™ll run into the issue Iā€™m referring to. The mail_image_system_path only updates once a day now, which means that the trigger wonā€™t trip but once a day, and if I restart my HA, I need to manually trigger the automation to force the update. I think weā€™ll need another trigger so the camera path is updated at boot, or we could update the camera definition to something other than /config/custom_components/mail_and_packages/mail_none.gif

Got it!. That must have sorted it!. Thank you so much!

Not critical but is there an easy way to add to the code so that each message is on a diferent line? Like
line breaks in old school html :slight_smile:

For some reason all of my pictures are displaying again. Not sure if I changed anything other than maybe clearing cache. Question on the pictures. I know that they show up sometime after the emails are received ( I believe for me five minutes). When does it change to no mail? I know yesterday I saw the pictures of my mail and last night it showed no mail. Also could anything be setup for the amazon picture to change from the picture of the delivery to a picture showing no delivery after a certain period, i.e 24 hours?

Midnight I believe.

And I think the Amazon image is like an alpha thing that Firstof9 was working on. Good idea with the no image after a period of time, might want to open an issue on GitHub for it so it can be tracked/logged. In the meantime could probably create a generic image and an automation to change the image path kinda like what is done with the mail image.

There is no longer a reason to update the camera to /config/custom_components/mail_and_packages/mail_none.gif using an automation. When the integration does not find mail images in the email, the generated random named gif file is the no mail image.

Since the local file camera doesnā€™t currently support templating for the file_path every restart resets the path to whatever you have defined in the configuration for the file_path.

There are two options to fix your issue.

  1. You can use the sensor.mail_updated as the trigger. This updates each time the integration checks email. It doesnā€™t appear to trigger the automation on the first run after a restart since it starts while home assistant is still loading. The second check will trigger the automation and update the camera.
  - alias: "Update USPS Mail Camera"
    trigger:
      - platform: state
        entity_id: sensor.mail_updated
    action:
      - service: local_file.update_file_path
        data_template:
          entity_id: camera.mail_usps
          file_path: "{{ states('sensor.mail_image_system_path') }}"
  1. Have two automations to update the file. One using any sensor that update due to mail change (sensor.mail_usps_mail, sensor.mail_updated, sensor.mail_image_system_path, etc). The second automation would be the same but use the home assistant platform start event as the trigger. Once the message that states things are still loading, home assistant officially is started and triggers the update to the camera.
  - alias: "Update USPS Mail Camera"
    trigger:
      - platform: state
        entity_id: sensor.mail_updated
    action:
      - service: local_file.update_file_path
        data_template:
          entity_id: camera.mail_usps
          file_path: "{{ states('sensor.mail_image_system_path') }}"

  - alias: "Update USPS Mail Camera"
    trigger:
      platform: homeassistant
      event: start
    action:
      - service: local_file.update_file_path
        data_template:
          entity_id: camera.mail_usps
          file_path: "{{ states('sensor.mail_image_system_path') }}"

Thanks, I think youā€™ve confirmed what I was seeing. I think Iā€™m going to run a combination of your examples

alias: Update USPS Mail Camera
trigger:
  - platform: state
    entity_id: sensor.mail_updated
  - platform: homeassistant
    event: start
action:
  - service: local_file.update_file_path
    data:
      file_path: '{{ states(''sensor.mail_image_system_path'') }}'
    entity_id: camera.mail_usps
mode: single
1 Like

I believe my issue with it not displaying is related to me not understanding how to implement the card correctly.
My automation from the card directions is:

- id: '123456001'
  alias: "Update USPS Mail Camera"
  trigger:
    - platform: state
      entity_id: sensor.mail_usps_mail

  action:
    - service: local_file.update_file_path
      data_template:
        entity_id: camera.mail_usps
        file_path: >
          {% if state_attr('sensor.mail_usps_mail','image') == None  %}
          /config/custom_components/mail_and_packages/mail_none.gif
          {% else %}
          /config/www/mail_and_packages/{{ state_attr('sensor.mail_usps_mail','image') }}
          {% endif %}

This sets the image, now I do not understand the camera settings as the old directions say to use:

camera:
  - platform: local_file
    file_path: /config/www/mail_and_packages/mail_today.gif
    name: mail_usps

I believe this is my issue as this points to the mail_today.gif file. How do I have the camera point to the new random file name or is it better to use:
gif_sensor: sensor.mail_image_url

Currently my card is setup to use
gif_sensor: sensor.mail_image_url

and the camera
is setup as false.

camera_entity: camera.mail_usps
    camera: false    

As I said sometimes this works and sometimes it doesnā€™t. Not sure why. It looks like the integration is setup correctly. Problem with how I am using the card.

Thanks. Sorry for my confusion in using the integration and card.
Bill

If you are going the camera route the automation needed was provided in the post you replied to. The path set in the the camera entity is fine, the first time the automation is triggered it will get replaced with the path from the sensor.mail_image_system_path.

If you choose to go the GIF route, you simply set the gif sensor to sensor.mail_image_url.

In the custom card config UI (pre-release v0.06) you toggle the blue switch above either GIF Sensor or Camera Entity depending on which you decide to use which is the same as the yaml below.

image: true
gif_sensor: sensor.mail_image_url
camera: true
camera_entity: camera.mail_image_url

Iā€™ve gone the GIF route and cannot get an image to populate when using the sensor.mail_image_url.

My previous working config is:

type: 'custom:mail-and-packages-card'
name: Mail Summary
updated: sensor.mail_updated
details: true
image: true
fedex_packages: sensor.mail_fedex_packages
ups_packages: sensor.mail_ups_packages
usps_packages: sensor.mail_usps_packages
amazon_packages: sensor.mail_amazon_packages
usps_mail: sensor.mail_usps_mail
camera: false
packages_delivered: sensor.mail_amazon_packages_delivered
packages_in_transit: sensor.mail_ups_delivering
gif: /local/mail_today.gif

But I donā€™t have a gif sensor listed. I do have the sensor.mail_image_system_path and sensor.mail_image_url available, but these donā€™t produce an image, only the url to the image.

What am I doing wrong?

3.1 wiki documentation is up. Those who were active in feature discussions and beta testing, please review for any holes or misinformation.

2 Likes

From your screen shot you are not using the pre-lease version 0.06 of the custom card that pairs with the 3.x version of the integration. The GIF field is now a Entity drop down similar to the Camera entity.

Ah, I thought I had it, thank you for the clarification, I usually just do the automatic updates. Iā€™ll get it installed.