Skip to content

Commit

Permalink
fixup! fixup! Migrate logbook card from entities to target
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-V committed Jan 6, 2025
1 parent c4dac0b commit ba441e1
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions dashboards/cards/house-feed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,52 @@ card:
title: "House feed"
hours_to_show: 24
target:
label_id: "house_feed"
entity:
- domain: "person"
label_id:
- "house_feed"
card_mod:
style: !template
file: ../styles/inset-icon.css.j2
variables:
background_size: "contain"
svg_path: "M6.18,15.64A2.18,2.18 0 0,1 8.36,17.82C8.36,19 7.38,20 6.18,20C5,20 4,19 4,17.82A2.18,2.18 0 0,1 6.18,15.64M4,4.44A15.56,15.56 0 0,1 19.56,20H16.73A12.73,12.73 0 0,0 4,7.27V4.44M4,10.1A9.9,9.9 0 0,1 13.9,20H11.07A7.07,7.07 0 0,0 4,12.93V10.1Z"
css: ".content ha-logbook { height: 330px; }"
card_param: "target.entities"
filter:
template: >-
{# Using a custom expand because the built-in expand only works on `group.*` #}
{% macro expand_ids(entity_id, include_groups = False) %}
{%- set ns = namespace(entity_ids = []) %}
{%- set entity = states[entity_id] %}
{%- if entity %}
{%- set children = entity.attributes.entity_id | default %}
{%- if children %}
{%- for entity_id in children -%}
{% set ns.entity_ids = ns.entity_ids + [expand_ids(entity_id, include_groups)] %}
{%- endfor %}
{%- if include_groups %}
{%- set ns.entity_ids = ns.entity_ids + [entity.entity_id] %}
{%- endif %}
{%- else %}
{%- set ns.entity_ids = ns.entity_ids + [entity.entity_id] %}
{%- endif -%}
{{ ns.entity_ids | join(',') }}
{%- endif %}
{%- endmacro %}

{{ ([
'binary_sensor.intrusion_activity',
'binary_sensor.presence_armed',
'fan.basement_bathroom',
'fan.main_bathroom',
] + expand_ids('light.basement_lights').split(',')
+ expand_ids('light.ground_floor_lights').split(',')
+ expand_ids('binary_sensor.all_doors').split(',')
+ expand_ids('binary_sensor.all_leaks').split(',')
+ expand_ids('binary_sensor.all_motions').split(',')
+ expand_ids('binary_sensor.all_windows').split(',')
+ expand_ids('group.household').split(',')
+ expand_ids('group.guests').split(',')
) | reject('eq', '')
| sort
}}
# Template to list entities that should be labeled with house_feed
# {# Using a custom expand because the built-in expand only works on `group.*` #}
# {% macro expand_ids(entity_id, include_groups = False) %}
# {%- set ns = namespace(entity_ids = []) %}
# {%- set entity = states[entity_id] %}
# {%- if entity %}
# {%- set children = entity.attributes.entity_id | default %}
# {%- if children %}
# {%- for entity_id in children -%}
# {% set ns.entity_ids = ns.entity_ids + [expand_ids(entity_id, include_groups)] %}
# {%- endfor %}
# {%- if include_groups %}
# {%- set ns.entity_ids = ns.entity_ids + [entity.entity_id] %}
# {%- endif %}
# {%- else %}
# {%- set ns.entity_ids = ns.entity_ids + [entity.entity_id] %}
# {%- endif -%}
# {{ ns.entity_ids | join(',') }}
# {%- endif %}
# {%- endmacro %}

# {{ ([
# 'binary_sensor.intrusion_activity',
# 'binary_sensor.presence_armed',
# 'fan.basement_bathroom',
# 'fan.main_bathroom',
# ] + expand_ids('light.basement_lights').split(',')
# + expand_ids('light.ground_floor_lights').split(',')
# + expand_ids('binary_sensor.all_doors').split(',')
# + expand_ids('binary_sensor.all_leaks').split(',')
# + expand_ids('binary_sensor.all_motions').split(',')
# + expand_ids('binary_sensor.all_windows').split(',')
# + expand_ids('group.household').split(',')
# + expand_ids('group.guests').split(',')
# ) | reject('eq', '')
# | sort
# }}

0 comments on commit ba441e1

Please sign in to comment.