Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

royalmail_deliveriestoday goes to unavailable - potentially after a delivery to my house of an item I was not tracking .... #8

Open
snigehere opened this issue Oct 2, 2024 · 9 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@snigehere
Copy link

I have noticed that the sensor royalmail_deliveriestoday goes to a state of "unavailable" ... potentially after a delivery to my house of a tracked item that was not in my tracking list.

I will try to monitor this in the coming weeks.

It would help to know where the "mail pieces" data come from? is it the tracking app or some other area of the account?

image

If I restart home assistant it correctly re-calculates to 0

I also seem to have one "mail piece" shown but don't know what it is ..
checking my online account, in the tracking section, I see three items shown, 2 marked as "In Transit" (but are from February this year) and one marked as "Sorry, we're not able to retrieve tracking information for this item" which I suspect is old.

Is it possible to add more detail, via attributes, to the mail pieces entity? maybe the tracking ID ?...

@jampez77
Copy link
Owner

jampez77 commented Oct 4, 2024

Hey, thanks for taking the time to log this bug!

The only time i have encountered this issue myself was due to hitting the API rate limit. I have done a release 2024.10.0 that aims to handle this by increasing the update interval to every 30 minutes. This is very much an experiment as there is no way of knowing what said limit is.

I've also refactored sensor.py. Like my Yodel integration there is now a single sensor for total parcels being tracked, the attributes will include two lists, parcels and out for delivery. These will be a list of parcel numbers.

Let me know if this improves your situation. I'll do what i can blindly but i've no parcels to track right now so i could very easily mess this all up even more.

@jampez77 jampez77 added bug Something isn't working help wanted Extra attention is needed labels Oct 4, 2024
@snigehere
Copy link
Author

Thanks for the update - I have installed the new release and will see what happens

@snigehere
Copy link
Author

Hi - thanks again for the new release ... I have an ancient parcel that shows as still pending so do get a record from the royal mail system.

What I see now is one sensor with the number of parcels and another sensor named after the parcel

I notice that the integration recycles every couple of hours - I guess that's when it checks for parcel updates ... each cycle makes the sensor become unavailable and then gets a value again.

image

There is a lot of information about the parcel as attributes so that's good ...

As the entity will have a different entity name for each parcel then the integration user will need to use a dynamic form such as "auto-entities" to pick up the parcel entities. To help with the process it would be good to include an attribute that could be used to pick out the parcel entities .. If I search for "royal mail" I also get the parcel count and update entities. I could use "carrierShortName" to work around this.

You mention you also do a yodal integration ... maybe it would be good to have a common attribute that would indicate a "parcel for delivery entity" to share across both integrations - that way, if wanted, someone can use one dynamic form to show parcels from both providers ... if they just want one then they can use "carrierShortName" as an additional filter.

As you don't have a pending parcel I am happy to share the attributes I see for the parcel if its of any help - just let me know.

Thanks again for your support.

@jampez77
Copy link
Owner

I'm loving all the detail, thanks!

So i've taken on you suggestion about the auto-entities and add _parcel_ to the entity id of each parcel. I've also done this for my Yodel and Evri integration so that should work with auto-entities if i'm not mistaken.

I've also refactored how the sensor entities are updated in the hope that this will stop the periodic unavailable status.

I don't have a RM parcel right now so it's done blind again, however I do have a Yodel parcel and it looks like it's working on there so lets hope it does here too.

The latest release is 2024.10.4 Good luck and thanks agian!

@snigehere
Copy link
Author

Thanks again - That's grand

I now have a single card I can use for all parcels from your integrations using a simple search criteria

I used a flex table card to give me tabular results - I need to reform the date but its the bones (I did mention its an ancient parcel that is left in my parcel list - I may get around to deleting it.... )

image

type: custom:auto-entities
card:
  type: custom:flex-table-card
  title: Parcels
  columns:
    - data: carrierShortName
      name: Provider
    - data: mailPieceId
      name: Parcel ID
    - data: summary_lastEventName
      name: status
    - data: summary_lastEventDateTime
      name: Last update
filter:
  include:
    - entity_id: "*_parcel_*"
  exclude: []

I installed your evri integration as we often get parcels from them .. it now means I can have one card on my home page with a hide if the parcel count is zero on both integrations and it will show deliveries from both. I may add yodel as we sometimes (rarely) get them from them.

I notices with evri it didn't ask me to authenticate ... is it using some already known value or a bug?

@jampez77
Copy link
Owner

That's a great little card! The auto-entities card is awesome and this is a perfect use case.

So i've done yet another update, that should, in theory at least, work much better to keep all entities updated with the latest changes from the server(s). I've also renamed the Tracked Parcels entities to be less generic i.e. Yodel Parcels etc

I've done it too the Yodel and RM integrations. I have been able to test Yodel as i currently have a parcel but not an RM one.

The Yodel and RM integrations synchronise your account data with those companies. I have yet to figure out quite how to do that with Evri so it separate to the account you might have with them. It can only see parcels you have added directly via HA right now. I will look again at fetching current tracked parcels like the other ones do soon. Last time i looked I couldn't see exactly how it was being done.

@mr0ney
Copy link

mr0ney commented Oct 15, 2024

Thanks again - That's grand

I now have a single card I can use for all parcels from your integrations using a simple search criteria

I used a flex table card to give me tabular results - I need to reform the date but its the bones (I did mention its an ancient parcel that is left in my parcel list - I may get around to deleting it.... )

image

type: custom:auto-entities
card:
  type: custom:flex-table-card
  title: Parcels
  columns:
    - data: carrierShortName
      name: Provider
    - data: mailPieceId
      name: Parcel ID
    - data: summary_lastEventName
      name: status
    - data: summary_lastEventDateTime
      name: Last update
filter:
  include:
    - entity_id: "*_parcel_*"
  exclude: []

I installed your evri integration as we often get parcels from them .. it now means I can have one card on my home page with a hide if the parcel count is zero on both integrations and it will show deliveries from both. I may add yodel as we sometimes (rarely) get them from them.

I notices with evri it didn't ask me to authenticate ... is it using some already known value or a bug?

Great card! Works well for RM, I have tried it with Evri and i just get undefined, have you managed to solve this?
image

@jampez77
Copy link
Owner

I created a template sensors which combines all the totals from each "tracked_parcels" sensor and then use this for the card

type: custom:auto-entities
card:
  type: entities
  title: Tracked Parcels
filter:
  include:
    - entity_id: "*_parcel_*"
  exclude: []
visibility:
  - condition: state
    entity: sensor.tracked_parcels
    state_not: "0"
show_empty: false

@mr0ney
Copy link

mr0ney commented Oct 15, 2024

That card shows me this
image

Im having issues with this card showing for evri parcels
image

This is what im getting, it worked fine for RM like above. I don't have a RM parcel atm to show that but i have an evri one that is just undefined
image

Let me know if im just being stupid about something 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants