Here’s a cool little something you can do with custom:button-card, picture-elements card, and the lovelace-gen custom_component. Thanks @thomasloven for lovelace-gen.
Javascript macros, and, the ability to place button-cards at x-y % locations on the screen. It made my floorplan setup manageable.
Here is an extract of the the fans-specific macro and usage.
# Fans x%, y%, widthpx, heightpx, border, background
{{ fan_button('switch.fan1', 21.6, 57.8, 41, 41, 'solid', 'silver') }}
{{ fan_button('switch.fan2', 47.4, 22.4, 60, 60, 'none', 'transparent') }}
{{ fan_button('switch.fan3', 37.8, 39.0, 33, 33, 'none', 'white') }}
and the code:
# lovelace_gen
id: floor_plan
title: Floor Plan
panel: true
cards:
- type: picture-elements
image: !file /local/images/FloorPlan.svg
elements:
{% macro fan_button(entity, x, y, width, height, border, background) -%}
- entity: {{entity}}
type: custom:button-card
style: { left: {{x}}%, top: {{y}}% }
show_name: false
show_label: false
show_entity_picture: true
styles:
card:
- width: {{ width }}px
- height: {{ height }}px
- background-color: {{ background }}
- border-style: {{ border }}
- border-width: 1.2px
- color: 'black'
state:
- value: 'on'
spin: true
entity_picture: /local/images/FanRed.png
- value: 'off'
entity_picture: /local/images/FanBlack.png
spin: false
{%- endmacro %}