Skip to content

PineappleEmperor/ocado-ha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

123 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

release commits-since-latest stars Dynamic Regex Badge
build build build

Ocado UK Integration for Home Assistant

This is an unofficial Ocado integration for Home Assistant. This integration creates several sensors with information about your next delivery, and when you can edit your next delivery.

I'd suggest creating a new email address and set up auto-forwarding on any emails you wish this integration, or any other IMAP integration to access.

⚠️ Please note this integration is in early development, there may be some rough edges and errors, so please submit any issues you come across!

Installation

HACS (Home Assistant Community Store)

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Configuration

Adding the Integration

  1. In Home Assistant, navigate to Configuration > Devices & Services.
  2. Click on Add Integration and search for "Ocado".
  3. Fill in the required fields similar to most IMAP-based integrations.

Configuration Options

You can configure the integration options by navigating to Configuration > Devices & Services, selecting the Ocado integration, and clicking on Options. Currently this is limited to:

Option Description
Scan interval How often you want to scan for new emails, by default this is every 10m, but it'll accept anything above every 5m.
IMAP days This is how many days in the past to scan for - if you prebook deliveries over a month in advance you may wish to extend this beyond the default 31d. If you reduce it too low the integration may not function correctly since it will miss important emails.

Features

Example Cards

Custom Button Card by @PineappleEmperor
Example Custom Button Card

Bubble Popup Card with Markdown by @PineappleEmperor
Example Bubble Card Popup with Markdown (for BBDs)

Tips & Tricks

  • I send a reminder to edit my next delivery via a notification an hour before the edit deadline. To do this I created a template sensor for the countdown and a datetime helper to store the current edit deadline:
Template Sensor
- name: "Ocado Edit Countdown"
    unique_id: ocado_edit_countdown
    availability: "{{ states('sensor.ocado_next_edit_deadline') not in ['unknown', 'unavailable', 'None', None] }}"
    icon: mdi:calendar-alert
    state: >
    {% set edit_deadline = states('sensor.ocado_next_edit_deadline')|as_datetime %}
    {% set edit_reminder = edit_deadline + timedelta(hours=-1) %}
    {% set now_datetime = states('sensor.date_time_iso')|as_datetime %}
    {% if (now_datetime.date() != edit_reminder.date()) %}
        -1
    {% elif edit_reminder.time() > edit_deadline.time() %}
        -1
    {% else %}
        {{ edit_deadline|time_until(precision=1)|replace(' hours','h')|replace(' minutes','m') }}
    {% endif %}
Automation
alias: Notify - Ocado Reminders
description: "Automation to send a reminder there's not much time left to edit the next Ocado order."
triggers:
- trigger: time
    at:
    entity_id: input_datetime.ocado_edit_reminder
    offset: "-01:00:00"
    id: edit_reminder
conditions: []
actions:
- choose:
    - conditions:
        - condition: trigger
            id:
            - edit_reminder
        sequence:
        - data:
            title: Ocado
            message: >-
                There's {{ states("sensor.ocado_edit_countdown") }} left to edit
                the Ocado order!
            action: notify.phones
mode: single

I also have a grocery budget 'pot' and an extension to the notification can inform me if I need to top up the pot based on the estimated total.

Devices & Sensors

The integration offers 2 devices. The first contains the details about upcoming orders:

Ocado (UK) Deliveries This device has 5 sensors:
Last Total Sensor

This sensor provides the last total using the email that is usually delivered a short time after a delivery.

It has two attributes:

Attribute Description
Updated This is the datetime of the email the info was taken from.
Order Number The order number associated with the total.
Next Delivery Sensor

This sensor provides the date of the next booked delivery using the collation of all "order is confirmed" emails available.

It has six attributes:

Attribute Description
Updated This is the datetime of the email the info was taken from.
Order Number The order number associated with the total.
Delivery datetime This is the datetime found for the next delivery.
Delivery window This is the delivery window found for the next delivery.
Edit deadline This is the edit deadline found for the next delivery.
Estimated total This is the estimated total found for the next delivery.
Next Edit Deadline Sensor

This sensor provides the datetime of the next order's edit deadline using the last "order is confirmed" email.

It has two attributes:

Attribute Description
Updated This is the datetime of the email the info was taken from.
Order Number The order number associated with the total.
Upcoming Delivery Sensor

This sensor provides the date of the next booked delivery after the next booked delivery using the collation of all "order is confirmed" emails available.

It has six attributes:

Attribute Description
Updated This is the datetime of the email the info was taken from.
Order Number The order number associated with the total.
Delivery datetime This is the datetime found for the upcoming delivery.
Delivery window This is the delivery window found for the upcoming delivery.
Edit deadline This is the edit deadline found for the upcoming delivery.
Estimated total This is the estimated total found for the upcoming delivery.
Orders Sensor (disabled by default)

This sensor provides a list (via its attribute) of all future orders that have been parsed by the integration. The state of the sensor is the datetime it was last updated.

It has a single attribute:

Attribute Description
orders This is the list of future orders that have been parsed by the integration.
Ocado (UK) Best Befores This device has a sensor for each day of the week:
{{day}} Sensor

This sensor provides number of best before dates on the chosen day/date.

It has four attributes:

Attribute Description
Updated This is the datetime of the email the info was taken from.
Order Number The order number associated with the total.
Date The date teh day falls on (i.e. the best before date).
BBDs The list of items with a best before date on this date.

Future Plans

  1. Testing 😅

About

Unofficial Ocado (UK) integration for Home Assistant.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages