Sometimes, great Home Assistant integrations come from the community, but not all of them are available through HACS. One such component is the Postcode Loterij custom component, created by Kevin van Hoorn. It’s not in HACS, but it’s definitely worth the (minimal) manual setup effort.
What is the Postcode Loterij?
The Postcode Loterij is a Dutch lottery where your postal code is your ticket number. Every month, prizes are drawn based on those postal codes.
Installation
Since this integration isn’t managed by HACS, you’ll need to install it manually. Here’s how:
- In your Home Assistant config directory, create the following path:
custom_components/postcodeloterij
- Head to Kevin’s GitHub repo and download the contents of the following folder: https://github.com/kvanhoorn/hass/tree/master/custom_components/postcodeloterij
- Update your
configuration.yaml
as mentioned below - Restart Home Assistant once again
Configuration.yaml
Make sure to replace 1234AB
with your postal code.
sensor:
- platform: postcodeloterij
postcode: 1234AB
When Does the Check Happen?
By default, the component checks for prizes from the previous month until the 8th of the current month. So if today is July 3rd, it still checks May’s results.
if (moment.day < 8):
moment = moment - dateutil.relativedelta.relativedelta(months=1)
I have commented out these lines, as I am to curious already earlier in the process to know if I’ve won + my automation depends on an earlier check.
Get Notified When You Win
What’s the fun in winning if you don’t get notified? Here’s a simple automation that checks the sensor on the 2nd day of each month at 14:00, and sends a notification if you’ve won something.
- id: postcodeloterij
alias: "Postcodeloterij: Prijs"
initial_state: 'on'
trigger:
platform: time
at: '14:00:00'
condition:
- "{{ now().day == 2 }}"
- "{{ states('sensor.postcodeloterij_prijs') | int(0) > 0 }}"
action:
service: notify.all_devices
data:
title: "Postcodeloterij uitslag"
message: "Deze maand heb je {{ states('sensor.postcodeloterij_prijs') }}x prijs! Namelijk {{ state_attr('sensor.postcodeloterij_prijs', 'prizes') }}. Gefelicteerd!"
data:
ttl: 0
priority: high
Note: If your prize count doesn’t change month-to-month (e.g., you win twice in a row), you’ll still get notified on the 2nd. It’s the earliest possible moment after most updates.
Conclusion
Thanks again to Kevin van Hoorn for creating this handy integration.
If you enjoy customizing your Home Assistant setup, the Postcode Loterij Sensor Integration is a fun and easy project, especially for Dutch users. It doesn’t take much effort to install, and who knows: you might just get a nice surprise notification one day.