Fixed for me, thanks!
Iām running b21 (just updated), but my Amazon sensor is reporting 3 packages, even though I donāt have any emails out. (i do have 1 package en-route today, but I never received an email for it). Itās been incorrectly reporting 3 Amazon packages for the last couple days
Logs at https://pastebin.com/bEYNBTKH
EDIT: When I review the sensor.mail_amazon_packages
entity, it just shows 1 order, which was shipped and delivered on Dec 28 (i used overnight shipping). Maybe the entity got confused when a new package was shipped and delivered on the same day?
Looks like something happened with the amazon forwarding bit, Iāll have a look.
Give b22 a shot. Based on my tests it should work properly now.
Iām trying to track the total number of packages arriving by combining all the mail sensors. Iām not very familiar with templates but this is what Iāve come up with. It validates and currently shows ā0ā (I donāt have any packages arriving).
Does this look right?
- platform: template
sensors:
packages_remaining:
friendly_name: Remaining Deliveries Today
icon_template: "mdi:package-variant-closed"
value_template: >-
{{ states.sensor.mail_amazon_packages.state | int - states.sensor.mail_amazon_packages_delivered.state | int +
states.sensor.mail_ups_packages.state | int - states.sensor.mail_ups_delivered.state | int +
states.sensor.mail_fedex_packages.state | int - states.sensor.mail_fedex_delivered.state | int +
states.sensor.mail_usps_packages.state | int - states.sensor.mail_usps_delivered.state | int }}
b22 seems to have fixed the issue. thanks
Most of that logic is already in the āIn Transitā sensor, the only thing youād need to keep is the amazon stuff.
So how would I add the amazon stuff to the āIn Transitā sensor?
My end goal is to add it to an Apple Watch complication. This is the example Iām trying to reach. I figured it was easier to match this template with a single sensor (that collected all sensors) vs adding each individual sensor.
apple_watch_packages_progress:
friendly_name: Apple Watch Packages Progress
icon_template: "mdi:package-variant-closed"
value_template: >-
{% if states.sensor.mail_amazon_packages.state | int == 0 %}
1.0
{% else %}
{{ (states.sensor.mail_amazon_packages_delivered.state | float) / (states.sensor.mail_amazon_packages.state | float) }}
{% endif %}
This should do it:
- platform: template
sensors:
packages_remaining:
friendly_name: Remaining Deliveries Today
icon_template: "mdi:package-variant-closed"
value_template: "{{ states('sensor.mail_packages_in_transit') | int + (states('sensor.mail_amazon_packages') | int - states('sensor.mail_amazon_packages_delivered') | int) }}"
EDIT: added missing 's
Does the āin transitā subtract the delivered or would I need make a template for delivered packages as well?
I want my watch to show how many are arriving with a graph indicating how many have already been delivered.
As āin transitā goes down ādeliveredā goes up.
Great so using your code, I added a 2nd entity for my wifeās amazon. Does this still look good?
- platform: template
sensors:
packages_remaining:
friendly_name: Remaining Deliveries Today
icon_template: "mdi:package-variant-closed"
value_template: "{{ states.sensor.mail_packages_in_transit.state | int + states.sensor.mail_amazon_packages.state | int + states.sensor.mail_amazon_packages_2.state | int - states.sensor.mail_amazon_packages_delivered.state | int + states.sensor.mail_amazon_packages_delivered_2.state | int }}"
And how would I add your sensor template to this sensor for the watch?
apple_watch_packages_progress:
friendly_name: Apple Watch Packages Progress
icon_template: "mdi:package-variant-closed"
value_template: >-
{% if states.sensor.mail_amazon_packages.state | int == 0 %}
1.0
{% else %}
{{ (states.sensor.mail_amazon_packages_delivered.state | float) / (states.sensor.mail_amazon_packages.state | float) }}
{% endif %}
Donāt use states.state use states().
EDIT: and using states() does not pass the template check. It results in an unavailable upon HA restart.
That covers the packages remaining sensor. What do I do about the delivered sensor?
Iām trying to replace the below code with all of my packages in transit and all of my packages delivered.
{% if states.sensor.mail_amazon_packages.state | int == 0 %}
1.0
{% else %}
{{ (states.sensor.mail_amazon_packages_delivered.state | float) / (states.sensor.mail_amazon_packages.state | float) }}
{% endif %}
Thank you for a fantastic component! Iām sure this info is out there somewhere, but I didnāt see it in the wiki and couldnāt easily find it in this forum post. Iām looking for a summary of exactly what each sensor means. I feel like there is something incorrect with my setup, but want to make sure. For example, should mail_packages_in_transit
show an aggregate count of all packages being delivered today? What is the difference between mail_ups_packages
and mail_ups_delivering
?
In my case, I have one package from UPS being delivered today, and the component has picked that up. But the only sensor that has been updated is mail_ups_delivering
(set to 1). But mail_ups_packages
is 0 and mail_packages_in_transit
is 0. Should those sensors have been updated as well?
My lovelace card looks like:
In the logs I see this regarding the UPS emails:
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Attempting to find mail from (['[email protected]']) with subject (Your UPS Package was delivered)
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] DEBUG imap_search: (FROM "[email protected]" SUBJECT "Your UPS Package was delivered" SINCE "31-Dec-2020")
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Searching for (['Tracking Number']) in (0) emails
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Search for (['Tracking Number']) count results: 0
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Search for (['[email protected]']) with subject (Your UPS Package was delivered) results: b'' count: 0
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Attempting to find mail from (['[email protected]']) with subject (Your UPS Packages were delivered)
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] DEBUG imap_search: (FROM "[email protected]" SUBJECT "Your UPS Packages were delivered" SINCE "31-Dec-2020")
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Searching for (['Tracking Number']) in (0) emails
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Search for (['Tracking Number']) count results: 0
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Search for (['[email protected]']) with subject (Your UPS Packages were delivered) results: b'' count: 0
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Attempting to find mail from (['[email protected]']) with subject (UPS Update: Package Scheduled for Delivery Today)
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] DEBUG imap_search: (FROM "[email protected]" SUBJECT "UPS Update: Package Scheduled for Delivery Today" SINCE "31-Dec-2020")
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Searching for (['Tracking Number']) in (0) emails
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Search for (['Tracking Number']) count results: 0
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Search for (['[email protected]']) with subject (UPS Update: Package Scheduled for Delivery Today) results: b'' count: 0
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Attempting to find mail from (['[email protected]']) with subject (UPS Update: Follow Your Delivery on a Live Map)
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] DEBUG imap_search: (FROM "[email protected]" SUBJECT "UPS Update: Follow Your Delivery on a Live Map" SINCE "31-Dec-2020")
2020-12-31 10:16:30 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Searching for (['Tracking Number']) in (3) emails
2020-12-31 10:16:31 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Found (['Tracking Number']) in email
2020-12-31 10:16:31 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Search for (['Tracking Number']) count results: 1
2020-12-31 10:16:31 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Search for (['[email protected]']) with subject (UPS Update: Follow Your Delivery on a Live Map) results: b'255' count: 1
2020-12-31 10:16:31 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] Searching for tracking numbers...
2020-12-31 10:16:31 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.helpers] No tracking numbers found
Thank you for any help!
Are you running the latest beta? b23 should be up.
I was running b23, but I updated after I saw this initial issue. So, I decided to uninstall and reinstall. But now, Iām getting an error on step 2 of the configuration page. āuser input malformedā.
Please check the Home Assistant log for error messages.
EDIT: You might need to enter ""
where the āAmazon forwarded email addressesā field is, Iāll have to take a look as to why itās causing an error.
Yeah, that was in there originally and I tried removing it. I just tried completely removing the integration and re-adding it using the beta version from the start and Iām still getting the āuser input malformedā error. But no error message is getting logged.
I also tried setting the folder back to INBOX and tried changing the options selected in the āsensors listā but I canāt get past this form.
Thanks so much.