-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NOT AN ISSUE, just giving something back to the community: Template to show today, coming days birtdays, events #101
Comments
for some reason this doesn't want to work for me :(, I cant get the formatting for the template right. Can you maybe post full template code? Thank you. |
Thanks! I've modified it a bit to add comma's between the birthdays if there are multiple on one day. Will be using this to send a message if someone has a birthday.
The result: (in Dutch..)
|
@MPCatnip If I try this to put in a lovelace template card, or in the Development Tools then it says: "UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'attribution'". Is this not working anymore? Or am I doing something wrong? |
Try adding the selectattr filter on your for line:
I believe its failing because some sensors won't have an attribute of attribution assigned, therefore fails when these are evaluated. This way you remove those by only selecting ones with the attribution attribute so you can then evaluate them. |
Here is a template to show the birthdays for coming week and today, i put this on my frontpage. With help from a community member:
|
@rononline thanks for posting this up, any chance you've copy/pasted it with a mistake? When I paste it into the template window, I get edit: hm, got it working with this:
|
Thanks for these examples. I'm going to leave them here in case they may help someone else. |
Little addition, because
|
My slight edit.
|
In case anyone needs it, I built myself a sensor to define todays anniversary to use in an automation(to select right music) based on the above code; - sensor:
- name: "Anniversaries Today"
unique_id: anniversaries_today
state: "{{expand(integration_entities('anniversaries')) | selectattr(\"state\", 'is_number') | selectattr(\"state\", 'match', '0') | map(attribute='name') | list | join(\", \") }}" |
Hi,
With the help from Jenny and a very friendly community member hereby a template that I could create to show the today events
{% for state in states.sensor -%} {%- if state.attributes.attribution == "Sensor data calculated by Anniversaries Integration" and state.state | int <= 0 -%} {{state.attributes.friendly_name}}: {{state.attributes.date }} current {{state.attributes.current_years }} years old, wil be {{state.attributes.years_at_next_anniversary }} years old {% endif -%} {%- endfor %}
Output: event: 27-02-2021 current 0 years old, wil be 1 years old
Just change the value
and state.state | int <= 1 -%}
to for instance 1 to get Today and tomorrow{% for state in states.sensor -%} {%- if state.attributes.attribution == "Sensor data calculated by Anniversaries Integration" and state.state | int <= 1 -%} {{state.attributes.friendly_name}}: {{state.attributes.date }} current {{state.attributes.current_years }} years old, wil be {{state.attributes.years_at_next_anniversary }} years old {% endif -%} {%- endfor %}
Today and next 2 days
{% for state in states.sensor -%} {%- if state.attributes.attribution == "Sensor data calculated by Anniversaries Integration" and state.state | int <= 2 -%} {{state.attributes.friendly_name}}: {{state.attributes.date }} current {{state.attributes.current_years }} years old, wil be {{state.attributes.years_at_next_anniversary }} years old {% endif -%} {%- endfor %}
and....
Use for instance with a TTS notification (https://github.com/rt400/ReversoTTS-HA)
Templates for in your config
Took me some time to figure this out so maybe helpful for other to?
Thanks again Jenny for the great integration, work and support to the community!
The text was updated successfully, but these errors were encountered: