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.
4/1
Grid with 2 columns
SAK Tool
Used for
Icon
Background Icon (only in first screenshot)
Circle
The half circle, as the left part of the circle is cutoff by the card
Icon
Entity Icon. Animated, state dependent and only visible if no entity_picture should be displayed
UserSvg
Shows the Entity Picture. Only visible if entity_picture should be displayed
Icon
Zone Icon, ie where is the person according to the zone configuration. Animated, state dependent
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_fce_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_fce_person:template:type:layoutdefaults:-sak_layout_fce_person_use_entity_picture:falselayout:aspectratio:4/1toolsets:# ================================================================# Extra background icon. Just for fun and filling some space-toolset:background-iconposition:cx:350cy:50tools:# -------------------------------------------------------------type:iconposition:cx:50cy:50align:centericon_size:100icon:mdi:map-marker-radius-outlinestyles:icon:fill:var(--theme-sys-elevation-surface-neutral2)# ================================================================-toolset:half-circleposition:cx:0# Center on cards border cy:50tools:# -------------------------------------------------------------type:circleposition:cx:50cy:50radius:50styles:circle:stroke:var(--theme-sys-color-secondary)stroke-width:3emopacity:0.5# ================================================================-toolset:column-iconposition:cx:25cy:50tools:# -------------------------------------------------------------type:iconposition:cx:50cy:50align:centericon_size:45entity_index:0variables:sak_layout_fce_person_use_entity_picture:'[[sak_layout_fce_person_use_entity_picture]]'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 'var(--theme-sys-color-primary)';return 'var(--theme-sys-color-tertiary)';]]]# Hide icon if using entity_picture!display:>[[[ if (tool_config.variables.sak_layout_fce_person_use_entity_picture) return 'none';return 'initial';]]]styles:icon:fill:var(--theme-sys-color-secondary)opacity:0.9# -------------------------------------------------------------type:usersvgposition:cx:50cy:50height:45width:45entity_index:0variables:sak_layout_fce_person_use_entity_picture:'[[sak_layout_fce_person_use_entity_picture]]'clip_path:position:cx:50cy:50height:40# Slightly crop image (from 45->40)width:40radius:all:20# Radius 20 results in full circlestyle:'images'images:# Fetch entity_picture from config or entity itself-default:>[[[if (tool_config.variables.sak_layout_fce_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_fce_person_use_entity_picture) return 'none';return 'initial';]]]# ================================================================-toolset:zone-iconposition:cx:40cy:18tools:# -------------------------------------------------------------type:circleposition:cx:50cy:50radius:14entity_index:0animations:# Return current state, so always a match!-state:'[[[returnstate;]]]'styles:circle:# Set fill depending on being at home or some unwanted state!fill:>[[[ if (state == 'home') return 'var(--theme-sys-color-primary)';if (state == 'not_home') return 'var(--brand-google-red)';if (['unavailable', 'unknown'].includes(state)) return 'black';return 'var(--theme-sys-color-tertiary)';]]]styles:circle:fill:var(--brand-google-red)stroke:var(--primary-background-color)stroke-width:2em# -------------------------------------------------------------type:iconposition:cx:50cy:50align:centericon_size:18entity_index:0variables:zone_ids:'[[sak_layout_fce_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)# ================================================================-toolset:column-nameposition:cx:70cy:50tools:# -------------------------------------------------------------type:nameposition:cx:50cy:37entity_index:0styles:name:text-anchor:startfont-size:30emfont-weight:700opacity:1# -------------------------------------------------------------type:stateposition:cx:50cy:70entity_index:0show:uom:nonestyles:state:text-anchor:startfont-size:26emfont-weight:500opacity:0.7