Lovelace – Custom Button
Home Assistant Template
Prompt user to confirm toggle of Entity
When switching items like PC’s make sure they meant it and include what is going to happen. So you need to prompt based on the sale of the entity.
You need to use a custom:button-card as the standard card confirmation does not include templating.
The formatting for this is in javascript/jquery an example is shown below note the odd back tick quotes for the strings.
- type: 'custom:button-card' tap_action: action: toggle confirmation: text: |- [[[ if (`${entity.state}` == "off") return `Turn ${entity.attributes.friendly_name} On?`; else return `Turn ${entity.attributes.friendly_name} Off?`; ]]] entity: switch.ebony_viii