Open pdwonline opened 6 months ago
First thing first, author, great work. Hope you don’t mind if I place here a link to my fork. https://github.com/notabene00/lovelace-home-feed-card
@pdwonline you can just add notabene00/lovelace-home-feed-card
to HACS and install from there.
I've implemented jinja2
templates support for content_template
, added condition
, attribute
options and made icon
templateable.
condition
, if defined, must be a jinja template string, if it renders to 'True', element will be displayed, otherwise - no.
attribute
parameter, if defined, must be an attribute name of the entity
that is a timestamp
or a datetime
and then attribute
s value will be used to calculate timediffs and display "state". can also be a template string.
icon
just can contain jinja2-templates now to be in sync with any entity's state changes.
Hi @notabene00 ,
I've added your fork. Could you please show few examples for condition usage and jinja2 syntax in content_template ? Thank you !
@Krakoukas73
Could you please show few examples
Sure. Here you go:
entities:
- entity: sensor.marinas_schedule
icon: mdi:human-female-female-child
condition: '{{ as_local(as_datetime(state_attr(entity, attribute))) > now() }}'
attribute: "{ 'end_date' if state_attr(entity, 'is_working_now') else 'start_date' }}"
content_template: >-
Марина {{ 'заканчивает' if state_attr(entity, 'is_working_now') else
'начинает' }} в {{ state_attr(entity, attribute).strftime('%H:%M') }}
Is something like this enough?
@notabene00
Thank you ! I'm confused. Native {{display_name}} and {{state}} are working Jinja is not interpreted. I am missing something
- entity: sensor.here_travel_time_duration_in_traffic
name: Temps de trajet avec Nico
content_template: >-
Native name: {{display_name}} <br><b><font size="5" color="#FF4444">
Native state: {{state}} </font></b><br>
Jinja2 : {{ 'заканчивает' if state_attr(entity, 'is_working_now') else 'начинает' }}
@Krakoukas73 I think you just didn't clear your browser's cache. Or have any other issue with resources.
Because it should be vice versa - "native" (for original card) {{state}}
option should not work anymore, as I removed it.
But really native (for Home Assistant) jinja2
support included and is working for me.
And I've synced repo with local copy just now. There was an issue with "attribute" being not passed into condition
template.
Thank you so much @notabene00 for your work and your time Working like a charm and as expected. Fantastic !
Hi Roman @notabene00 !
I'm using intensively your custom home-feed-card to centralize all alerts from 1.5K+ automations and it is awesome. Thank you. Below is the visual rendering. After that, alerts from home-feed are compiled, submited to Extended OpenAI Conversation and summarized with TTS.
sort order was reversed from originale : newest items are bottom, oldest are on top. Everything else works perfecty :-) I used card-mod for this :
#notifications { display: flex; flex-direction: column-reverse; }
- entity: sensor.xxx
condition: '{{ int(states(entity)) > 40 }}'
int
might be replaced with float
to meet your needs
- entity: sensor.xxx
condition: "{{ states(entity) not in ['1','4','29'] }}"
if you need to exclude several states using templates
Oh, I seem to be responding to something that is no longer in your post
new ordering paradigm is not a bug (maybe once I'll add a config parameter with ordering options) at first, I was doing this fork for personal use my use case implies direction from the past to the future
Oh, I seem to be responding to something that is no longer in your post
Sorry. Being upset for days with conditions syntax. Asking GPT : correct syntax in milliseconds. I should asked OpenAI before replying here
I'm confused again
condition
is a condition for an entity to be shown, not to be hiddenstates()
function returns a string
anything else I can help you with?
Nothing to add @notabene00 : awesome fork, great feedback and explanations. Thank you so much ! I'm using it thought scripts & automations every 45sec 24/24
Would be nice to be able to hide entities based an expression or value of a sensor like this: