Closed dooz127 closed 4 years ago
You can always add entity:
to the configuration - even if it does nothing - and it will be counted as used.
Ah, good point. So I like this approach because to do something similar, I previously had this as my yaml:
card:
entities:
- entity: camera.front_door
secondary_info: '${ ''Last Activity: '' + vars[0] }'
type: 'custom:secondaryinfo-entity-row'
show_header_toggle: false
title: Cameras
type: 'custom:hui-entities-card'
entities:
- entity: camera.front_door
- entity: sensor.ring_front_door_last_activity
type: 'custom:config-template-card'
variables:
- >-
new Date(states['sensor.ring_front_door_last_activity'].attributes['created_at'].valueOf()).toLocaleString('en-US')
This is really hard to understand. Now my yaml can be:
entities:
- entity: camera.front_door
icon: mdi:camera # or entity_picture: '{{ state_attr(''camera.front_door'',''entity_picture'') }}'
name: '{{ state_attr(''camera.front_door'',''friendly_name'') }}'
secondary: >-
Last Activity: {{
as_timestamp(states['sensor.ring_front_door_last_activity'].attributes.created_at)
| timestamp_custom("%x %I:%M %p") }}
state: '{{ states(''camera.front_door'')|title }}'
type: 'custom:template-entity-row'
show_header_toggle: false
title: Cameras
type: entities
It would be even better if it could be:
entities:
- entity: camera.front_door
secondary: >-
Last Activity: {{
as_timestamp(states['sensor.ring_front_door_last_activity'].attributes.created_at)
| timestamp_custom("%x %I:%M %p") }}
type: 'custom:template-entity-row'
show_header_toggle: false
title: Cameras
type: entities
Awesome. Thank you so much!!!
It would be awesome if
entity
was a configuration option in whichlovelace
would use defaultentity
attribute values if not user-defined and the module would override an attribute if defined by the user. For example, my yaml right now is:With the feature, the yaml could be shortened to:
Another small benefit of this approach is the entity is no longer categorized as an unused entity.