Lovelace: PostNL

You always have a choice. Just overwrite the custom component and change it to your likings :slight_smile: You can just concatenate all data yourself within the python code.

wouldn’t know what… btw Im not using a custom component, but the builtin component.

this is what the docs say: https://www.home-assistant.io/components/postnl/#configuration

so I did that :wink:

any suggestion I should do otherwise?

Read the opening post. It instructs you to set up a custom component. It’s not compatible with the current component.

Really sorry, missed that, and jumped on thinking it was only a custom card for Lovelace.

1 Like

No problem :slight_smile:

Thanks for making this! love it.

1 Like

I too have installed this, great component. 2 questions, 1, would it be able to rename this component so that I could use this alongside the official one?

I had some pretty complex notification automations that extracted time/date information etc.
Not that I can’t make them with these though, but it would save me a great deal of time.

If it isn’t possible to have this custom component running alongside the official it is not a big deal.

The other question I have is, would it be possible to show more photo’s of letters instead of only the first one? So that we could scroll through the photo’s by means of e.g. the swiper card?

Great component btw!

1 Like

Thanks Jim! If you rename the component directory then I think you can have them running along side each other. I am just not sure if I should mark this one as the new official component of HA. That would be my ultimate plan, just have to check with the original author.

Could you give me some examples of automations you would make? I am not sure if I can add something to aid in that though, but I can always have a look!

Swiper card sounds like an awesome idea! I add it to the list!

Currently I use automations like this, but like I said I can probably make it for this component (I’m just lazy at the moment haha).

- alias: PostNL Stephanie
  trigger:
    - platform: state
      entity_id: sensor.postnl_stephanie
  condition:
    condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.postnl_stephanie
        above: 0
      - condition: numeric_state
        entity_id: sensor.postnl_stephanie
        below: 2
  action:
    - service: notify.ios_notifier
      data_template:
        message: >-
          {% set s= trigger.to_state.attributes.shipments[0]['status']['formatted']['short'] %}
          {% set t1 = (s|regex_findall_index('time:[^T]*T[^+-]*',0)).replace('time:','') %}
          {% set d = t1.split('T')[0] %}
          {% set t1 = t1.split('T')[1].rsplit(':',1)[0] %}
          {% set t2 = (s|regex_findall_index('time:[^T]*T[^+-]*',1)).replace('time:','').split('T')[1].rsplit(':',1)[0] %}
          Er is {{ trigger.to_state.state }} pakketje onderweg voor Stephanie van {{ trigger.to_state.attributes.shipments[0]['title'] }}. Bezorgtijd op {{ d }} tussen {{ t1 }} en {{ t2 }}.
        title: 'PostNL Stephanie'

@ptnijssen
Great work.

1 Like

What I think I can do, but I have to check, is to make sure that there is a trigger when a package is arriving today, so you can perform an action on that. I will check if that is something that I can do.

In regards to your “complicated” script, let me see if I can extract some of that data already within the API library. That would already make it more easier and would probably also make my card easier.

For now, you can see the available variables for packages over here:
https://github.com/peternijssen/postnlpy/blob/master/postnlpy/items/package.py

Sounds great, funny that you quoted the “complicated” automations. Well for me they are, I am not a programmer. I work as a bartender and kids entertainer :stuck_out_tongue:

No worries, no offense taken, I just thought it was funny. I am guessing this is like driving a bike for you :wink:

2 Likes

I have the component working but why am I seeing the date in american notation ?
I have my timezone setting set to Europe/Amsterdam and unit_system set to metric.

date_format_error

Hadn’t noticed it until you mentioned it, indeed it looks kind of weird knowing that this component is made for the Dutch :stuck_out_tongue:

Actually, I based it on the browser settings;
https://github.com/peternijssen/lovelace-postnl/blob/master/postnl-card.js#L282

I will have a look if it can be based on the settings in HA.

Haha. I didn’t ment it like that. I do think indeed it’s over complicated for what it should be or could be :wink:

For me the whole python part is completely new and javascript is not my strongest point. The only luck I have is that I have a developer background :wink:

I only did basic HTML a long time ago and basic PHP/MYSQL.

I used to do webdesign in the early days, but man that is like 15/20 years ago.

Ah yes, I have all my browsers and OS set in English, I hate the Dutch language for these kind of things. But I do like our own date notation :smiley:.

I have a question, would it be possible to get rid of the card name? (The default PostNL with that icon?). It takes up too much space for what I want. I tried to remove the name/icon from your postnl-card.js file and although it does remove the name/icon from all existing cards, it does not remove the empty space, so it basically is still the same card with the same height, but just without a name.

Edit: the reason I ask is because I use a lot of pop-up cards in my setup, they are great. However you can’t scroll on these cards, so I would like to save as much space as I can, but without sacrificing my litte top menu:

I know that if any more will come that the card won’t fit anyways but I will find a better solution in the future.

Maybe reverse the numbering of packages so that newest one always is number 0?

Then you know when using number 0 is always the latest. Or is there a Jinja2 way to ‘select the highest available number’?

Because:
Currently using states.sensor.postnl_delivery.attributes.enroute.0.planned_date in an automation so I just got notified about a package of March because that is stuck on ‘on the way’ and a new one entered the system with number being 2. 1 is also a stuck one. :laughing: I know you can remove it in the PostNL application but then the whole order is gone.

Seems like {{ states.sensor.postnl_delivery.attributes.enroute[-1].planned_date }} might be a solution. Maybe using minus results in reverse order. Because -2 and -3 are the other ones.

Good point! I’ve tried to handle the dates on the Python side, but I had a hard time converting a string to a datetime. I’ll add it to the git repo to give it another try.