Thinks like Mushroom Template for example, where you might have icon colour states for say ranges of fridge temperatures etc and other complex templating setups.
Now how to manage changes to these when copies appear on several dashboards?
Best I can come up with is have an Admin only Master Template Dash that is where buttons are designed and live, and Copy+Paste the button YAML over to all dashboards that use them.
But I was wondering if there was a way to #include the config for one in its entirety from a central store? I don’t think there is, but maybe I missed it…
Or whether anyone had other strategies they use?
ALSO: Why does the lovelace editor have “Cut/Copy” option on the buttons in the GUI but no apparent Paste option anywhere?
Addendum:
Well, so far I’ve come up with this:
Template Sensor to pull from the various sensors that the Bosch Home Connect integration exposes from a washing machine:
- sensor:
# Washing Machine primary
# Primary state is a hint to display or hide as Visibility can only be set based on state, not attributes
- name: "Dash Washer"
unique_id: dashtemplate_washer
icon: mdi:washing-machine
state: >-
{%
set opStateDisplay =
{
'run': true,
'delayedstart': true,
'finished': true,
'actionrequired': true,
'error': true,
'aborting': true,
'pause': true,
}
%}
{% set displayState = opStateDisplay.get(states.sensor.washy_mcwashface_operation_state.state, false) %}
{{ displayState }}
attributes:
primary: Washer
secondary: >-
{%
set opState =
{
'run': 'Running',
'ready': 'Ready to Start',
'inactive': 'Ready to Start',
'delayedstart': 'Delayed Start',
'finished': 'Finished',
'actionrequired': 'Problem!',
'error': 'Problem!',
'aborting': 'Cancelled',
'pause': 'Paused',
}
%}
{% set primInfo = opState.get(states.sensor.washy_mcwashface_operation_state.state, 'Unknown') %}
{% set finish = '' %}
{% set prefix = 'Finish:' %}
{% if states.sensor.washy_mcwashface_operation_state.state == 'finished' %}
{% set prefix = 'at' %}
{% endif %}
{% if states.sensor.washy_mcwashface_programme_finish_time.state == 'unavailable' %}
{{ primInfo }}
{% else %}
{{ primInfo }} {{ states.sensor.washy_mcwashface_programme_finish_time.state | as_datetime | as_timestamp | timestamp_custom(prefix + ' %H:%M') }}
{% endif %}
icon_colour: >-
{%
set opState =
{
'run': 'yellow',
'ready': 'green',
'inactive': 'green',
'delayedstart': 'yellow',
'finished': 'blue',
'actionrequired': 'red',
'error': 'red',
'aborting': 'yellow',
'pause': 'yellow',
}
%}
{% set highlightColour = opState.get(states.sensor.washy_mcwashface_operation_state.state, 'Unknown') %}
{{ highlightColour }}
badge_icon: None
badge_colour: white
picture: None
And the associated button:
type: custom:mushroom-template-card
secondary: "{{ state_attr(entity, 'secondary') }}"
icon_color: "{{ state_attr(entity, 'icon_colour') }}"
grid_options:
columns: 12
rows: 1
primary: "{{ state_attr(entity, 'primary') }}"
layout: horizontal
multiline_secondary: false
fill_container: false
tap_action:
action: none
hold_action:
action: none
double_tap_action:
action: none
visibility:
- condition: state
entity: sensor.normalised_washer
state: "True"
icon: "{{ state_attr(entity, 'icon') }}"
entity: sensor.dash_washer
badge_icon: "{{ state_attr(entity, 'badge_icon') }}"
badge_color: "{{ state_attr(entity, 'badge_colour') }}"
picture: "{{ state_attr(entity, 'picture') }}"
This has the advantage that all the logic is back in one place.
And for things where I want to use this type of button, I can literally copy/paste the button and change the entity name. And probably never have to edit it again, save for visibility and layout, which genuinely might vary from dashboard to dashboard.