Thanks for your code and tips! For others trying to get it to work, here are some more detailed instructions (credit to @dmatik for the code!) when using Lovelace in UI mode:
First we need to prepare by adding the sensors used by the card:
- Add the following sensors to your config.yaml:
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- platform: template
sensors:
my_date:
friendly_name: "Date"
icon_template: mdi:calendar
value_template: >-
{{ as_timestamp(strptime(states('sensor.date'), '%Y-%m-%d')) | timestamp_custom("%a, %b %d") }}
Then the following to get the actual card:
- Download the button_card.js component from https://github.com/custom-cards/button-card
- Save the button_card.js file in /config/www/button_card.js
- Go to your lovelace dashboard, press ‘Edit Dashboard’ at top right (3 dots menu)
- Click on ‘Manage resources’ under top right menu (3 dots)
- Click ‘ADD RESOURCE’, with URL: ‘/local/button_card.js’ and Resource Type ‘Javascript Module’ (both without quotes)
- Possibly you have to restart home assistant server here, TBH I can’t remember. From the top of my head it is not necessary.
- Go back to Lovelace editor and press “ADD CARD”. Choose “Custom: Button-Card”
- Use the code editor to enter the following card code (credits to @dmatik ):
type: custom:button-card
entity: ''
styles:
card:
- padding: 4%
- font-size: 52px
- border-radius: var(--button-card-border-radius)
- background-color: var(--button-card-background-color)
- color: var(--primary-text-color)
grid:
- grid-template-areas: '"time date"'
- grid-template-columns: 2fr
- grid-template-rows: 1fr
custom_fields:
time:
- justify-self: start
date:
- justify-self: end
- font-size: 20px
- color: var(--secondary-text-color)
custom_fields:
time: |
[[[ return states['sensor.time'].state ]]]
date: |
[[[ return states['sensor.my_date'].state ]]]
tap_action: none
hold_action: none
- Save your card and you should be done!
Result looks as follows: