The two cards on this page show how same_as, calc(), constants, groups, and ref() can reduce repetition in complete card configurations.
Each example includes the full YAML, making it easier to see which parts are defined once, which parts are reused, and how the final layout is positioned.
The first small circle defines the shared local position, radius, and styling. The other two reuse that definition and receive their final position from their assigned group.
circles:-id:firstgroup:L1xpos:calc(centerX - 3)ypos:calc(centerY - 3)radius:2styles:-fill:var(--primary-text-color)-opacity:0.5-id:secondgroup:L2same_as:first-id:thirdgroup:L3same_as:first-id:bigonexpos:calc(centerX)ypos:calc(-centerY)radius:175# Radius in pixelsstyles:-fill:var(--primary-background-color)-opacity:0.7-stroke:var(--disabled-text-color)-stroke-width:2
The grouped state definitions follow the same pattern. The first phase state defines the local layout, and the other two reuse it within their own groups.
constants:radius0:5000# Large radius used to emulate a straight horseshoexpos0:20# Horizontal position of the first horseshoeypos0:45# Vertical position of the first horseshoedxPos1:25# Horizontal shift from Total to L1dxPos2:21# Horizontal shift between the remaining phases
horseshoes:-entity_index:0xpos:calc(-radius0 + xpos0 + 5)ypos:45radius:calc(radius0)rotate:-90# Rotates the horseshoe 90 degrees counterclockwisearc_degrees:0.7# A large radius requires a very small arcflip:y# Flips the Y-axis so zero appears at the bottomshow:horseshoe:truescale_tickmarks:falsehorseshoe_style:colorstopgradientscale_style:fixedlabels_at:ticks_majorticks:truelabel_badges:truelabel_background:nonehorseshoe_scale:min:0max:5width:6color:var(--primary-background-color)ticksize:0.1# One tick every 0.1 kWhgap:3styles:-opacity:0.7horseshoe_tickmarks:ticks_major:ticksize:1color_mode:colorstopgradientwidth:12offset:-3thickness:1styles:-stroke:var(--primary-text-color)-fill:var(--primary-text-color)-opacity:0.9ticks_minor:ticksize:0.1color_mode:colorstopgradientthickness:1width:6offset:-12styles:-stroke:var(--primary-text-color)-fill:var(--primary-text-color)-opacity:0.7horseshoe_labels:distance_min:0.3ticksize_min:0.3orientation:horizontaloffset:-34badges:radius:6color:var(--card-background-color)border_color:var(--divider-color)padding:0height:10styles:-font-size:0.7emhorseshoe_state:width:12styles:-stroke-linecap:buttcolor_stops:gap:3colors:0:var(--fhs-sys-rainbow-blue)1:var(--fhs-sys-rainbow-green)2:var(--fhs-sys-rainbow-yellow)3:var(--fhs-sys-rainbow-orange)4:var(--fhs-sys-rainbow-red)5:var(--fhs-sys-rainbow-purple)
The other three horseshoes need only a few lines of YAML.
The L1 horseshoe reuses the complete Total configuration, shifts to the right, and hides the labels. L2 and L3 each reuse the previous horseshoe and move right by the same calculated offset.
This avoids repeating the full horseshoe definition three more times.