This card shows you some possibilities to apply JavaScript to the animations section
The card seems like a standard, simple card, but isn't due to some Home Assistant functionalities and the possibilities of using either an icon or an entity picture for the person.
The use of JavaScript to fetch the zone's Icon, to do some state dependent color changes and taking care of the "use entity_picture yes/no" setting are nice examples of the possibilities that JavaScript adds to tools. It are just a few lines, but very powerful!
It also takes care of fetching the icon of additional zones (ie not the home zone).
Description
Aspect Ratio
Target Size
A card that shows in which zone a person is, or if in no known zone as away / not home.
The list of zone entities for this person to be displayed. There is no limit, it is really a list which is used when the person is not at home!
sak_layout_person_use_entity_picture
false
If set to true, an entity picture is displayed instead of the persons icon. Default the picture configured for the person is used, but can be overridden by specifying an entity_picture in the entity configuration in the view
sak_layout_fce2_person:template:type:layoutdefaults:-sak_layout_person_use_entity_picture:false-sak_layout_person_icon_color:var(--theme-sys-color-primary)-sak_layout_person_icon_color_on:var(--theme-sys-color-error)-sak_layout_person_history_disabled:false-sak_layout_person_history_color_on:var(--theme-sys-color-error)layout:aspectratio:1/1toolsets:# ================================================================-toolset:background-iconposition:cx:50cy:50tools:# -------------------------------------------------------------type:'usersvg'position:cx:50cy:30height:100width:100clip_path:position:cx:50cy:50height:60width:100radius:all:0style:'images'images:-default:"/local/images/backgrounds/map-background.jpg"styles:usersvg:opacity:0.8mask:fill:url(#sak-sparkline-area-mask-tb-0)# ==============================================================================-toolset:circle-with-iconposition:cx:20cy:20tools:# -------------------------------------------------------------type:circleposition:cx:50cy:50radius:12.5entity_index:0animations:-state:'on'styles:circle:stroke:var(--theme-sys-color-error)-state:'off'styles:circle:# stroke: var(--theme-sys-elevation-surface-neutral10)stroke:'[[sak_layout_person_icon_color]]'styles:circle:stroke-width:2em# stroke: var(--theme-sys-elevation-surface-neutral10)stroke:'[[sak_layout_person_icon_color]]'fill:var(--primary-background-color)# -------------------------------------------------------------type:iconposition:cx:50cy:50align:centericon_size:20entity_index:0variables:sak_layout_person_use_entity_picture:'[[sak_layout_person_use_entity_picture]]'sak_layout_person_icon_color:'[[sak_layout_person_icon_color]]'animations:# Return current state, so always a match!-state:'[[[returnstate;]]]'styles:icon:# Set fill depending on being at home!fill:>[[[ if (['home', 'not_home'].includes(state)) return tool_config.variables.sak_layout_person_icon_color;return 'var(--theme-sys-color-secondary)';]]]# Hide icon if using entity_picture!display:>[[[ if (tool_config.variables.sak_layout_person_use_entity_picture) return 'none';return 'initial';]]]styles:icon:fill:var(--theme-sys-color-secondary)opacity:0.9# -------------------------------------------------------------type:usersvgposition:cx:50cy:50height:20width:20entity_index:0variables:sak_layout_person_use_entity_picture:'[[sak_layout_person_use_entity_picture]]'clip_path:position:cx:50cy:50height:20# Slightly crop image (from 45->40)width:20radius:all:10# Radius 20 results in full circlestyle:'images'images:# Fetch entity_picture from config or entity itself-default:>[[[if (tool_config.variables.sak_layout_person_use_entity_picture) {return (entity_config?.entity_picture ||entity.attributes?.entity_picture || 'none');} else {return 'none';}]]]animations:# Return current state, so always a match!-state:'[[[returnstate;]]]'image:defaultstyles:icon:# Hide usersvg tool if using icon!display:>[[[ if (!tool_config.variables.sak_layout_person_use_entity_picture) return 'none';return 'initial';]]]# - template:# name: tool_valmardav_icon# ==============================================================================-toolset:nameposition:cx:7.5cy:45tools:# -------------------------------------------------------------type:nameposition:cx:50cy:50entity_index:0show:ellipsis:12styles:name:text-anchor:startfont-size:12emfont-weight:700opacity:1# -------------------------------------------------------------type:stateposition:cx:50cy:62.5entity_index:0show:uom:nonestyles:state:text-anchor:startfont-size:10emfont-weight:400opacity:0.6# ==============================================================================-toolset:alert-time-boxesposition:cx:50cy:75tools:# -------------------------------------------------------------type:rectexposition:cx:20cy:50width:25height:18radius:left:5right:0entity_index:0animations:-state:'home'operator:'!='styles:rectex:fill:var(--theme-sys-color-error)-state:'home'styles:rectex:fill:var(--theme-sys-elevation-surface-neutral10)styles:rectex:fill:var(--theme-sys-elevation-surface-neutral10)# -------------------------------------------------------------type:iconposition:cx:20cy:50align:centericon_size:12.5entity_index:0variables:zone_ids:'[[sak_layout_person_zone_entities]]'animations:# Return current state, so always a match!-state:'[[[returnstate;]]]'# Fetch icon of zone. If no match on zone, the state 'not_home' is given.# Check that state, and return the 'not home' icon in that case!icon:>[[[ if (state == 'not_home') return 'mdi:home-off-outline';if (state == 'home') return states['zone.home'].attributes.icon;// For not home, we get the friendly name as input. Must find that one to retrieve// the zone's id...for (var i=0; i<tool_config.variables.zone_ids.length; i++) {var zone = states[tool_config.variables.zone_ids[i]];if (zone && zone.attributes.friendly_name == state) {return states[zone.entity_id].attributes.icon;}}return 'mdi:map-marker-question';]]]styles:icon:fill:var(--primary-background-color)styles:icon:fill:var(--primary-background-color)# -------------------------------------------------------------type:rectexposition:cx:64cy:50width:57height:18radius:left:0right:5entity_index:0animations:-state:'home'styles:rectex:fill:var(--theme-sys-elevation-surface-neutral4)-state:'home'operator:'!='styles:rectex:fill:var(--theme-sys-elevation-surface-error4)styles:rectex:fill:var(--theme-sys-color-on-error)# -------------------------------------------------------------type:stateposition:cx:64#92cy:50entity_indexes:-entity_index:1-entity_index:0animations:-state:'home'entity_index:0styles:state:fill:var(--theme-sys-elevation-surface-neutral10)-state:'home'entity_index:0operator:'!='styles:state:fill:var(--theme-sys-color-error)styles:state:# fill: var(--theme-sys-color-error-container)fill:var(--theme-sys-color-error)font-size:12emtext-anchor:middle#end# alignment-baseline: middlefont-weight:700uom:# fill: var(--theme-sys-color-error-container)fill:var(--theme-sys-color-error)alignment-baseline:hangingfont-weight:600# ==============================================================================-toolset:alert-historyposition:cx:50cy:92.5tools:# -------------------------------------------------------------type:sparkline# When disabled, SAK will not use this tooldisabled:'[[sak_layout_person_history_disabled]]'entity_index:0position:cx:50cy:50width:85height:3margin:0period:calendar:period:dayoffset:0duration:hour:24bins:per_hour:1sparkline:show:chart_type:barcode# chart_variant: stalagmitesstate_map:template:name:sak_statemap_person# State value settings# - set agg to max to see the binary changes# - set lower_bound to -1 to offset 'off' state# the barcode will start wider now, instead of at minimum width# - set upper_bound to 1 ('on') to fix upper scalestate_values:aggregate_func:maxlower_bound:-1upper_bound:1barcode:column_spacing:3line_width:0.1colorstops_transition:hardcolorstops:colors:-value:0color:var(--theme-sys-elevation-surface-neutral10)-value:1color:'[[sak_layout_person_history_color_on]]'styles:tool:opacity:1barcode_graph:rx:5ry:5