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

Thank you, that helped me get the camera image updated within Home Assistant but not sure I can use it in Node Red to send the GIF. Still trying to figure it out.

That would be great, if you do decide to update. I’m very new to Node Red so not quite sure what to do with all the data I get from doing what you suggested. I’ve tried using a switch node but I think I have the JSON wrong.

On the first side of the screen just look at the debugger.
You should be able to expand and eventually find the image…

I haven’t had time to update, but here is an example of what it looks like before updating.
I expect the attribute is where you’ll find it… but you’re looking for an image tag:

1 Like

Yup that’s as far as I got. No clue where to go from here.

image

Awesome, that’s it… you can see your image there… so next to it there is a clipboard that will copy the path or the value… copy the path and you can use it elsewhere.

So, where ever you want to put the image name, use {{data.attributes.image}}.
OR if you are using a function node, its msg.data.attributes.image.
I believe this is because other nodes use mustache template, but function node does not.

Hope that helps!
DeadEnd

This should work @Jeremy_S . It won’t catch if there’s no mail, I gotta work on that. (SEE EDIT) TBH I’ll probably just disable the random image name as I don’t really need it since the path for me isn’t public anymore. Hope that’s coming soon @firstof9

[{"id":"916e36b5.b8b428","type":"api-call-service","z":"1fe83a7f.e0f0b6","name":"Update Image","server":"63517380.eb951c","version":1,"debugenabled":false,"service_domain":"local_file","service":"update_file_path","entityId":"camera.usps_mail","data":"{ \"file_path\": \"/config/images/mail_and_packages/{{payload}}\" }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":420,"y":1700,"wires":[[]]},{"id":"f1eae158.c7849","type":"api-render-template","z":"1fe83a7f.e0f0b6","name":"Test","server":"63517380.eb951c","template":"{% if state_attr('sensor.mail_usps_mail','image') == None  %}\nmail_none.gif\n{% else %}\n{{ state_attr('sensor.mail_usps_mail','image') }}\n{% endif %}","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"","templateLocationType":"none","x":250,"y":1700,"wires":[["916e36b5.b8b428"]]},{"id":"c44bdd94.af8dd","type":"server-state-changed","z":"1fe83a7f.e0f0b6","name":"Camera Update","server":"63517380.eb951c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.mail_usps_mail","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":100,"y":1700,"wires":[["f1eae158.c7849"]]},{"id":"63517380.eb951c","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

EDIT: Ok I figured out how to do the mail_none.gif bit using a template node. You’ll need to have the mail_none.gif in the same path as your mail_today.gif (or what WAS mail_today.gif…). Code above is updated to reflect the change.

EDIT 2: Nope, not working @firstof9 I’m using your suggestion here https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/issues/70#issuecomment-610675419 but the problem is the image path seems to update more frequently than the sensor, so with there being no change to the sensor itself, the image path isn’t updated so the camera entity is broken. Gonna revert for now until the disable switch is available.

The image file name changes each mail check and the attribute is updated along with it.

Correct, but from what I can see it’s not causing the sensor to be updated (or at least HASS to think it is) because the state value isn’t changing. So therefore the path isn’t being updated and the automation isn’t working. Work around would be to create a template sensor to change when the attribute changes I guess.

Odd the attributes field updates and triggers the camera filename to be updated each time for me.

Beta 11 available :wink:
Gives you a toggle for the filename randomness :smiley:

2 Likes

You sir are a rock star.

Hi all! This looks great guys, so thank you! I am currently setting up and Gmail is going crazy, I am bombarded with security alerts, and had to turn on “Less Secure App Access”. Am I missing a way to do 2-factor Auth? Thanks again!

Use an App Password https://support.google.com/accounts/answer/185833?hl=en

I’m confused that you had to do something to figure out the mail_none.gif bit? The only image that needs to be referenced for any purpose is the mail_today.gif that is generated. If there is no mail the integration copies the mail_none.gof stored in the custom_component folder out to the image path in the integrations configuration as mail_today.gif or the new random UUID string naming convention.

@fuzzymistborn So what you’re saying is that Node Red requires a sensor value to change in order to trigger an automation in Node Red?

Then I guess I didn’t hahaha. I was trying to emulate this automation in NR:

https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/issues/70#issuecomment-610675419

And yes it seems that’s the case that NR requires a state change to trigger. There may be another way that I’m not familiar with.

Quick question, can anyone point me to where I need to go to change the color of the UPS, USPS, Mail, and FedEx labels on the Mail and Packages custom card? I am color blind and have a very hard time making out the words. Ideally I would like to change them to just white.

I opened the two JavaScript files in the cards folder with Notepad++ but nothing jumped out at me. Admittedly I am not entirely sure what I am looking at in those files so I may have just missed it.

Thanks!

I would assume they’re controlled by your current theme.

I have tried about 10 different themes and the colors of those words don’t change that’s why I thought maybe it had something to do with how the card was configured.

Colors are within the CSS that start on line 202 of the mail-and-packages-card.js file. The icon color is set by the theme your home assistant is using and the text for each carrier is a hyperlink and has no color customization from this card.

I haven’t worked with any HASS theming so I’m not sure what all can be defined. Like @firstof9 said colors for hyperlinks could be defined in a HASS theme, but ultimately by the browser. They should be the same color as other non style hyperlinks on other websites.

You can add the following after line 207 and customize the differs link color attributes. This should limit the changes to this card.

        /* unvisited link */
        .details li a:link {
          color: red;
        }

        /* visited link */
        .details li a:visited {
          color: green;
        }

        /* mouse over link */
        .details li a:hover {
          color: hotpink;
        }