All Projects → point-4ward → ps-date-countdown

point-4ward / ps-date-countdown

Licence: Unlicense license
A python script for Homeassistant that counts down the days to birthdays, anniversaries etc

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to ps-date-countdown

lovelace-light-soft-ui-theme
🎨 Home Assistant soft UI light theme, with help from @JuanMTech, @thomasloven, and @N-l1.
Stars: ✭ 59 (+180.95%)
Mutual labels:  homeassistant, hacs
ha-eskom-loadshedding
Fetches loadshedding data from Eskom
Stars: ✭ 48 (+128.57%)
Mutual labels:  homeassistant, hacs
ha-sengledapi
Home Assistant Integration for Sengled Bulbs. This is a custom component to allow control of Sengled Bulbs in Homeassistant using the unofficial Sengled API. Please note this mimics the Sengled app and therefore Sengled may cut off access at anytime.
Stars: ✭ 85 (+304.76%)
Mutual labels:  homeassistant, hacs
charger-card
A lovelace card for electrical vehicle (EV) home chargers and charging robots.
Stars: ✭ 57 (+171.43%)
Mutual labels:  homeassistant, hacs
power-distribution-card
A Lovelace Card for visualizing power distributions.
Stars: ✭ 117 (+457.14%)
Mutual labels:  homeassistant, hacs
home-assistant-theme-outline
🎨 Home Assistant Theme: Outline
Stars: ✭ 20 (-4.76%)
Mutual labels:  homeassistant, hacs
homeassistant-coronavirus-hessen
[Unmaintained] Home Assistant component to scrape the current SARS-CoV-2 data for the German state of Hessen from the website of the Hessisches Ministerium für Soziales und Integration.
Stars: ✭ 15 (-28.57%)
Mutual labels:  homeassistant, hacs
HomeAssistant-Cupertino-Icons
Apple SF Symbols icons for Home Assistant! (3000+ icons)
Stars: ✭ 100 (+376.19%)
Mutual labels:  homeassistant, hacs
ledfxrm
Custom Integration for Home Assistant to control a any (local/remote) LedFX-server - State: beta
Stars: ✭ 31 (+47.62%)
Mutual labels:  homeassistant, hacs
hass-miwifi
MiWiFi for Home Assistant
Stars: ✭ 116 (+452.38%)
Mutual labels:  homeassistant, hacs
atomic-calendar-revive
An advanced calendar card for Home Assistant Lovelace.
Stars: ✭ 218 (+938.1%)
Mutual labels:  homeassistant, hacs
home-assistant-flair
Custom component for Home Assistant Core for Flair pucks, vents, rooms, structures, and minisplits
Stars: ✭ 51 (+142.86%)
Mutual labels:  homeassistant, hacs
midea-ac-py
This is a library to allow communicating to a Midea appliance via the Midea cloud.
Stars: ✭ 72 (+242.86%)
Mutual labels:  homeassistant, hacs
plugwise-beta
Custom-component / development version of the Plugwise Home Assistant platform
Stars: ✭ 23 (+9.52%)
Mutual labels:  homeassistant, hacs
homeassistant-jlrincontrol
An integration for JLR InControl to Home Assistant
Stars: ✭ 34 (+61.9%)
Mutual labels:  homeassistant, hacs
home-assistant-omnik-inverter
Read the current, daily and total Wh from your Omnik Inverter via local network (no cloud!)
Stars: ✭ 45 (+114.29%)
Mutual labels:  homeassistant, hacs
home-assistant-miele
Miele integration for Home assistant
Stars: ✭ 101 (+380.95%)
Mutual labels:  homeassistant, hacs
custom-brand-icons
Custom brand icons for Home Assistant
Stars: ✭ 242 (+1052.38%)
Mutual labels:  homeassistant, hacs
homeassistant-afvalwijzer
Provides sensors for some Dutch waste collectors
Stars: ✭ 119 (+466.67%)
Mutual labels:  homeassistant, hacs
fullscreen-card
Make your Home Assistant browser fullscreen with one tap.
Stars: ✭ 23 (+9.52%)
Mutual labels:  homeassistant, hacs

Date Countdown

A python script for Homeassistant that counts down the days to birthdays, anniversaries etc

hacs_badge

Important note

I no longer use homeassistant so if this script stops being compatible with homeassistant that will be the end of the line. That said, it hasn't needed any maintenence in over a year and was working well so it will probably be fine to use for a long while yet.

How it works

This script creates a sensor that a counts down to the next occurrence of a date, like a birthday or anniversary and gives the number of years as an attribute.

You can optionally reverse the counter so it counts up from the last occurrence of a date, such as when you quit smoking.

Requires python_script: to be enabled in your configuration

Installation

Copy the Python script in to your /config/python_scripts directory or install via HACS.

Script arguments

key required type description
name: True string Name of the date (eg. John)
type: True string Type of date (eg. Birthday)
date: True string Date, in format DD/MM/YYYY
friendly_name: False string Display name of the sensor
append_year: False boolean Appends the number of years to the friendly name
icon: False string Icon of the sensor, defaults to 'mdi:calendar-star'
reverse: False boolean Reverses the sensor to count up instead of down. (Defaults to False)

The date can be in the future if you want to countdown to the date itself, and then the anniversaries thereafter.

Usage

Each sensor requires:

name: NAME_OF_DATE
type: TYPE_OF_DATE
date: DD/MM/YYYY_OF DATE

You can also customize the sensor icon and friendly names :

icon: "mdi:ICON_OF_DATE"
friendly_name: FRIENDLY_NAME_OF_DATE
append_year: True

And you can reverse the sensor so it counts up from a date:

reverse: True

examples:

name: John
type: birthday
date: 17/08/1971

or

name: Our wedding
type: anniversary
date: 14/02/1994
icon: "mdi:ring"
append_year: True

or

name: Quit Smoking
type: celebration
date: 01/10/2008
reverse: True

Generated sensors

Each sensor is given the following automatically:

entity_id: sensor.<type>_<name>
friendly_name: <name> <type>
state: <Days to the date from today>
nextoccur: <Date of next occurance>
years: <Number of years it will be>

So, the three sensors we created above would come out as:

sensor.birthday_john
friendly_name: John’s birthday
state: However many days it is until 17th August
nextoccur: 17/08/YYYY (either this year or next year as appropriate)
years: However old John will be on his next birthday

sensor.anniversary_our_wedding
friendly_name: Our wedding anniversary (20)
state: However many days to 14th February
nextoccur: 14/02/YYYY (either this year or next year as appropriate)
years: How many years you will have been married on that day

sensor.celebration_quit_smoking
friendly_name: Quit smoking celebration
state: However many days SINCE 1st October
nextOccur: 01/10/YYYY (either this year or next year as appropriate)
years: How many years SINCE you quit smoking

Note that if the type is 'birthday' the sensor will automatically add an apostrophe.

Example configuration.yaml entry

An example automation to create and refresh the above three sensors daily would be:

automation:
  - alias: Reminder - Refresh date countdown sensors
    trigger:
      - platform: time
        at: '00:00:01'
      - platform: homeassistant
        event: start
    action:
      - service: python_script.date_countdown
        data:
          name: John
          type: birthday
          date: 17/08/1971
      - service: python_script.date_countdown
        data:
          name: Our wedding
          type: anniversary
          date: 14/02/1994
          icon: "mdi:ring"
          append_year: True
      - service: python_script.date_countdown
        data:
          name: Quit smoking
          type: celebration
          date: 01/10/2008
          reverse: True

Example automation

An example automation to remind you of an event 7 days before it occurs would be:

automation:
  - alias: Reminder - John's birthday is coming up
    trigger:
      - platform: state
        entity_id: sensor.birthday_john
        to: '7'
    action:
      - wait_template: "{{ states('sensor.time') == '10:00' }}"
      - service: notify.notify
        data:
          message: "John's birthday is only a week away!"

Example Lovelace representation

Utilising the attributes provided and the custom lovelace card for adding secondary info to an entity row.

type: entities
show_header_toggle: false
title: Our Events
entities:
  - entity: sensor.anniversary_our_wedding
    secondary_info: '[[ {entity}.attributes.nextoccur ]]  ( [[ {entity}.attributes.years ]] Years )'
    type: 'custom:secondaryinfo-entity-row'

Will provide the following lovelace representation:

Lovelace example

Credits

Thanks to @myle for the idea for the extra attributes and the lovelace presentation.

Thanks to AJax2012 for the PR that caters for future dates, and makes the apostrophes in the friendly names only append to birthday sensors.

Thanks to Cyrosy for adding customization options and fixing some bugs.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].