Picnic.app integration

I saw that there was some interest in a custom component for Picnic.app. I am not an avid user of Home Assistant myself (yet), but I wanted to contribute to this amazing project. Therefore I reverse engineered the android app.

You can follow the instructions here for installation and usage:

Also, these are my first projects, so feedback is welcome!
The integration hasn’t been tested fully yet!

I would like to thank @ptnijssen and his jumbo integration for allowing me to use parts of his code.

8 Likes

Thanks!
I’ve installed it, so far so good anyway, will need to do some groceries :wink:

Works great! Thank you.
Exaclty what I needed and good sensors.

Thanks for making an effort!
If I understand correctly, it is not possible to add items to basket from the integration. Is this something you plan to add in the future? Would it be possible?

That would be possible for sure!
I was’t planning on doing this in the short term, since I don’t know in what way this would be implemented (interface wise). Would this be done through an automation or lovelace card?

First I want to finish the notification system (since there are still some problems with it :wink:) and my development cycle is somewhat limited due to me only being able to preform real tests once a week when I order from picnic :sweat_smile:

1 Like

The way I would see it, would be setting up several sensors around the house that measure when something is out of stock. Then via HA automation it could be added to the basket. Perhaps via a service with as data the item that needs to be added. Just an idea.

I’ll be following this project with interest.

1 Like

Has somebody examples of how they are using this integration on their lovelace?
maybe maps can be used to see picnic driving :stuck_out_tongue:

1 Like

Hey guys,

Sorry for the radio silence of the last months. I’ve been busy with wrapping up my masters degree + was moving.

I didn’t have the time yet to setup HA and hence can’t really test or use my integration atm + picnic has put me on the waiting list for my current area! So testing from my part will be limited.

I have 2 questions:

  • Could someone provide me some automation examples for the github readme (and maybe help out Ferrymug
  • Provide me some info on how to make the feature that @repjas sugested above

Thanks in advance!

Thanks for the picnic integration! I’m just learning to deal with it …
I solved that with this template:

  • platform: template
    sensors:
    picnic_liefer_zeit_anfang:
    friendly_name: “Picnic Lieferzeitfenster Start”
    icon_template: mdi:clock-outline
    value_template: ‘{{as_timestamp(states.sensor.picnic_delivery.attributes[“delivery”][“window_start”]) | timestamp_custom ("%d-%m-%Y %H:%M") }}’

I use this sensor to get informed one hour before the time window closes to order goods:

  • platform: template
    sensors:
    picnic_order_last_chance:
    friendly_name: “Picnic letzte Chance "
    value_template: '{{as_timestamp(states.sensor.picnic_delivery.attributes[“delivery”][“cut_off_time”]) | timestamp_custom (”%d-%m-%Y %H:%M") }}’

This is my automation:

  • id: ‘XXXXXXXX’
    alias: Picnic letzte Chance
    description: Das Zeitfenster zum Befüllen des Warenkorbs endet in 1 Stunde
    trigger:
    • platform: template
      value_template: “’{{ (((states.sensor.picnic_order_last_chance.state)| int) -
      \ as_timestamp(states.sensor.date.state\n + ‘’ ‘’ + states.sensor.time.state)
      \ |int ) - 3690 < 0 }}’”
      condition: []
      action:
    • service: input_boolean.toggle
      data: {}
      entity_id: input_boolean.shopping_list_message
    • service: notify.ha_nachricht
      data:
      message: XXXXXXXX

Hi Mike and Schreg,

I have also implemented this succefully. However i had to modify the automation a little bit (maybe due to regional settings?).

Here is what I added in the configuration.yaml:

sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
  - platform: picnic
    username: !secret picnic_usr
    password: !secret picnic_pw
    country_code: "NL" 
  - platform: template
    sensors:
        picnic_delivery_start:
          friendly_name: Picnic Delivery timslot Start
          icon_template: mdi:clock-outline
          value_template: "{{ as_timestamp(states.sensor.picnic_delivery.attributes['delivery']['window_start']) | timestamp_custom ('%d-%m-%Y %H:%M') }}"

and here is the automation I use:

alias: Picnic in 30 mins
description: ''
trigger:
  - platform: template
    value_template: >-
      {{as_timestamp(states.sensor.picnic_delivery.attributes['delivery']['window_start'])
      - as_timestamp(states.sensor.date.state + " " + states.sensor.time.state)
      - 1800 < 0}}
condition: []
action:
  - service: notify.persistent_notification
    data:
      message: Picnic in 30 minutes
      title: Notification
mode: single

Great integration. Works perfectly.

Just to get some people up and running below you can find some template examples:

// Show all upcoming (available timeslots)
{% for timeslot in state_attr('sensor.picnic_delivery_time_slots', 'time_slots') -%}
{% if timeslot.is_available == true -%}    
  {{
    as_timestamp(timeslot.window_start) | timestamp_custom('%a %b %d, %H:%M') 
    + ' - ' 
    + as_timestamp(timeslot.window_end) | timestamp_custom('%H:%M') 
  }}     
{% endif -%}
{% endfor %}

// Results
Thu Feb 11, 21:00 - 22:00     
Fri Feb 12, 18:15 - 19:15     
Sat Feb 13, 21:00 - 22:00     
Sun Feb 14, 15:30 - 16:30     
Mon Feb 15, 11:30 - 12:30     
Mon Feb 15, 21:00 - 22:00

// Setup integration (Use secrets)
- platform: picnic
  username: !secret picnic_username
  password: !secret picnic_password
  country_code: "NL"

// Create a friendly template sensor
- platform: template
  sensors:
    picnic_next_delivery_formatted:
      friendly_name: "Picnic Next Delivery"
      value_template: "{{ 
        as_timestamp(state_attr('sensor.picnic_delivery', 'delivery').window_start) 
        | timestamp_custom('%a %b %d, %H:%M') 
        + ' - ' 
        + as_timestamp(state_attr('sensor.picnic_delivery', 'delivery').window_end) 
        | timestamp_custom('%H:%M') 
      }}"
      icon_template: mdi:truck-delivery
    picnic_first_available_timeslot_formatted:
      friendly_name: "Picnic First Available Timeslot"
      value_template: "{% set ns = namespace(found=false) %}
        {% for timeslot in state_attr('sensor.picnic_delivery_time_slots', 'time_slots') -%}
        {% if timeslot.is_available == true and ns.found == false -%}    
          {{
            as_timestamp(timeslot.window_start) | timestamp_custom('%a %b %d, %H:%M') 
            + ' - ' 
            + as_timestamp(timeslot.window_end) | timestamp_custom('%H:%M') 
          }}  
          {% set ns.found = true %}
        {% endif -%}
        {% endfor %}"
      icon_template: mdi:calendar-clock
1 Like