amaximus / anniversary Goto Github PK
View Code? Open in Web Editor NEWAnniversary integration for Home Assistant
License: MIT License
Anniversary integration for Home Assistant
License: MIT License
I am trying to set up an anniversary list to coincide with our state and national holidays, which I have created as independent sensors using Calendarific. This way the holiday dates are always accurate, because it would pull the current information from the api that Cakenarific uses.
Here is the code I am trying to run, but the sensor: sensor.holidays does not contain any data:
Calendarific Created sensor attributes:
date: '2022-01-01'
description: >-
New Year's Day is the first day of the Gregorian calendar, which is widely
used in many countries such as the USA.
attribution: Data provided by calendarific.com
unit_of_measurement: Days
friendly_name: New Year's Day
icon: mdi:calendar-blank
Hi! Great idea! Thanks for creating this.
I have 0.2.2 version installed but I can't see in the button-card to events that will happen the same day.
That's what I have in configuration.yaml:
And that's the custom button-card (it is the one you published as an example):
type: custom:button-card
size: 30px
styles:
label:
- font-size: 90%
card:
- height: 80px
icon:
- color: var(--paper-item-icon-color)
grid:
- position: relative
custom_fields:
notification:
- background-color: |
[[[
if (states['sensor.anniversary_events'].state > 1)
return "var(--light-primary-color)";
return "var(--accent-color)";
]]]
- border-radius: 50%
- position: absolute
- left: 62%
- top: 10%
- height: 20px
- width: 20px
- font-size: 9px
- line-height: 20px
custom_fields:
notification: |
[[[ return states['sensor.anniversary_events'].state ]]]
label: |
[[[
var label = states['sensor.anniversary_events'].attributes.first_event_name
return label.replace("|","
");
]]]
color_type: icon
show_label: true
show_name: false
entity: sensor.anniversary_events
Thanks in advance for your help.
In my event list have have two people listed who share a birthday
eg
` - event: 'Person 1'
date: '1982-05-13'
icon: mdi:cake-variant
type: 'birthday'
- event: 'Person 2'
date: '2003-05-13'
icon: mdi:cake-variant
type: 'birthday' `
However using
{{state_attr('sensor.events','events')|list}}
Only returns person 2 and not both. Obviously as they have different birth years I would prefer both so I know what birthday cards I need. We have 23 nephews and nieces so it would be helpful, not to miss any.
Hi. Is it possible to do below? I want to add type for the anniversary so when i have my button card i can use entity_picture and change the picture based on if state is equal to birthday or new year for example.
sensor:
platform: anniversary
name: events
multiple: true
anniversaries:
- event: 'Jasons birthday'
date: '1987-06-22'
type: birthday
- event: 'Johannas birthday'
date: '1991-10-18'
type: birthday
- event: 'new year'
date: '12-31'
type: 'new year'
After install from HACS and restart of hassio, it is not visible in the integrations tab.
Is this add-on still in development? The sensor shows nothing. I have HA version 2022.10 with example code. State and attributes are empty.
sensor:
- platform: anniversary
name: events
multiple: true
anniversaries:
- event: 'Doug birthday'
date: '2000-1-15'
- event: 'Steve Butabi'
date: '2000-09-15'
icon: mdi:cake-variant
- event: 'Chazz birthday'
date: '9-15'
icon: mdi:cake-variant
- event: 'Frank the tank'
date: '1998-8-18'
Thank you very much for this useful integration.
I currently have Birthdays and Anniversaries in the set up and use a different icon for each, however this is not included in the events list, so I can not include when outputting the list of upcoming events using a template.
Ideally I would like to be able to define a type field to use to condition the output easily for notifications on my morning schedule like
Nick's 52nd birthday in 4 days, Nick and Jeannnette's 25th wedding anniversary in 39 days.
and if possible include the type and the icon in the events list on the sensor attributes.
After the update it stopped working giving the following error:
ButtonCardJSTemplateError: TypeError: Cannot read properties of undefined (reading 'attributes') in 'var label = states['sensor.events'].attributes.first_event_name return label.replace("|","<br>")...'
tap_action:
action: more-info
type: custom:button-card
group_expand: false
hold_action:
action: none
double_tap_action:
action: none
layout: vertical
size: 30px
color_type: icon
show_name: false
show_state: false
show_icon: true
show_units: true
show_label: true
show_entity_picture: false
show_live_stream: false
card_size: 3
styles:
label:
- font-size: 90%
card:
- height: 80px
icon:
- color: var(--paper-item-icon-color)
grid:
- position: relative
custom_fields:
notification:
- background-color: |
[[[
if (states['sensor.events'].state > 1)
return "var(--light-primary-color)";
return "var(--accent-color)";
]]]
- border-radius: 50%
- position: absolute
- left: 62%
- top: 10%
- height: 20px
- width: 20px
- font-size: 9px
- line-height: 20px
custom_fields:
notification: |
[[[ return states['sensor.events'].state ]]]
label: |
[[[
var label = states['sensor.events'].attributes.first_event_name
return label.replace("|","<br>");
]]]
entity: sensor.events
default_color: var(--primary-text-color)
color_off: var(--paper-item-icon-color)
color_on: var(--paper-item-icon-active-color)
lock:
enabled: false
duration: 5
unlock: tap
Would you mind providing an example on how you configured the button component in Lovelace?
Thanks for this integration ,
I'd like to add the example button card to my ui ,
i actually copy paste it as is:
type: custom:button-card
size: 30px
styles:
label:
- font-size: 90%
card:
- height: 80px
icon:
- color: var(--paper-item-icon-color)
grid:
- position: relative
custom_fields:
notification:
- background-color: >
[[[
if (states['sensor.events'].state > 1)
return "var(--light-primary-color)";
return "var(--accent-color)";
]]]
- border-radius: 50%
- position: absolute
- left: 62%
- top: 10%
- height: 20px
- width: 20px
- font-size: 9px
- line-height: 20px
custom_fields:
notification: >
[[[ return states['sensor.events'].state ]]]
label: >
[[[
var label = states['sensor.events'].attributes.first_event_name
return label.replace("|","<br>");
]]]
color_type: icon
show_label: true
show_name: false
entity: sensor.events
getting error:
ButtonCardJSTemplateError: TypeError: Cannot read properties of undefined (reading 'attributes') in 'var label = states['sensor.events'].attributes.first_event_name return label.replace("|","<br>")...'
tap_action:
action: more-info
type: custom:button-card
....
I saw this was asked before and is closed now. (Was fixed) but i have this problem.
I have 2 persons birthday on the same day and month and different year but it only shows 1 person at first_event_name.
How to fix this?
sensor:
- platform: anniversary
name: Anniversarys
date_format: '%A %d %B %Y'
multiple: true
anniversaries:
- event: 'name1'
date: '1979-5-22'
icon: mdi:face-man
- event: 'name2'
date: '2007-1-1'
icon: mdi:face-man-outline
after a restart of HA the following appears in the log:
Logger: homeassistant.components.sensor
Source: custom_components/anniversary/sensor.py:57
Integration: Sensor (documentation, issues)
First occurred: 9:11:11 AM (1 occurrences)
Last logged: 9:11:11 AM
anniversary: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 646, in async_device_update
await task
File "/config/custom_components/anniversary/sensor.py", line 149, in async_update
anni_date_p = _get_anniversary_date(self, i, today_p.year)
File "/config/custom_components/anniversary/sensor.py", line 57, in _get_anniversary_date
mydate_p = datetime.strptime(self._anniversaries[i]['date'], self._date_format)
File "/usr/local/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/local/lib/python3.9/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '1979-5-22' does not match format '%A %d %B %Y'
Hi, I have not found any mistake but I would like to ask whether it would not be added to integration see the attributes of the entity next 4 anniversaries. Currently, only the first is visible. thank you
hello, I put the card as an example, with a birthday test on 2/09 but the card is not displayed. However I put this in the map:
Sensor.yaml
Card:
type: conditional
conditions:
in edit mode, the card is present, with the birthday, but in normal mode, it disappears
What is the cause ?
thanks.
I want to create event every week, month. How I can do it?
All my sensors are working but I can't get the "type" attribute to show up. Below example.
- event: 'Jack and Lizzy'
date: '2016-07-16'
icon: mdi:party-popper
type: Anniversary
I have an event as follows
- platform: anniversary
name: events
multiple: true
items: 3
anniversaries:
- event: 'Jeannette'
date: '1970-01-02'
icon: mdi:cake-variant
type: birthday
However the value for the age at next birthday is currently showing as 51, when it should be 52. I suspect this might be to do with the fact the birthday is in the following year, as the other two birthday ages which are in December are showing correctly.
first_event_name: Christa
first_event_in: 15
first_event_on: '2021-12-25'
anniversary: 76
events:
- event: Christa
event_in: '15'
event_on: '2021-12-25'
anniversary: '76'
type: birthday
icon: mdi:cake-variant
- event: Stephen
event_in: '16'
event_on: '2021-12-26'
anniversary: '60'
type: birthday
icon: mdi:cake-variant
- event: Jeannette
event_in: '23'
event_on: '2022-01-02'
anniversary: '51'
type: birthday
icon: mdi:cake-variant
friendly_name: events
icon: mdi:cake-variant
How is this different than https://github.com/pinkywafer/Anniversaries?
hello,
this is to put in the sensor.yaml?
like this:
and he has to take back the anniversary of the next three, is that right?
I have events configured like this:
platform: anniversary
name: events
multiple: true
anniversaries:
- event: 'Name'
date: '1998-10-9'
The card properly shows up in the UI. When I open the card and also open attributes, it shows the details. The last line shows Anniversary: 22
and I guess this is the number of years since the original event. Shouldn't that be 23 in my example?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.