Trying to create a dashboard with dynamic times slots every 30 minutes

Hi All

Been trying to get this working for about a week

I have the octopus-energy-rates-card working fine and wanted to have a column of on-off buttons in a column to the right of the rates for the rest of the day which could be 11:00 at the point of opening the dashboard so I only wanted the right button column to align row by row and only show buttons from 11:00 this is so I can control 2 heavy usage appliances and Aga cooker and Immersion heater via wifi switches.

I just can’t get the dynamic button switches to work any help would be much apricated :slight_smile:

title: Agile Schedule & Rates
type: custom:layout-card
layout_type: custom:grid-layout
layout:
  grid-template-columns: 45% 55%
  grid-template-rows: auto
  grid-gap: 10px
cards:
  - type: custom:octopus-energy-rates-card
    title: Agile Rates
    sort_by:
      - relative-time
    display_options:
      secondary_info:
        - time
    currentEntity: >-
      event.octopus_energy_electricity_**************************_current_day_rates
    futureEntity: event.octopus_energy_electricity_**************************_next_day_rates
    rateListLimit: 48
    hour24: true
    cols: 1
  - type: vertical-stack
    cards:
      - type: custom:template-card
        template_mode: yaml
        entity_id: sensor.date # Forces a refresh
        content: |
          {% set current_datetime = now() %}
          {% set half_hour_slots = ['0000', '0030', '0100', '0130', '0200', '0230', '0300', '0330', '0400', '0430', '0500', '0530', '0600', '0630', '0700', '0730', '0800', '0830', '0900', '0930', '1000', '1030', '1100', '1130', '1200', '1230', '1300', '1330', '1400', '1430', '1500', '1530', '1600', '1630', '1700', '1730', '1800', '1830', '1900', '1930', '2000', '2030', '2100', '2130', '2200', '2230', '2300', '2330'] %}
          
          {% set card_list = [] %}
          
          {% for slot in half_hour_slots %}
            {% set slot_hour = slot[:2] | int %}
            {% set slot_minute = slot[2:] | int %}
            {% set slot_time = current_datetime.replace(hour=slot_hour, minute=slot_minute, second=0, microsecond=0) %}
          
            {% if slot_time >= current_datetime - timedelta(minutes=15) %}
              {% set card_list = card_list + [
                {
                  'type': 'custom:button-card',
                  'template': 'half_hour_slot',
                  'entity': 'input_boolean.schedule_slot_' ~ slot,
                  'name': slot[:2] ~ ':' ~ slot[2:]
                }
              ] %}
            {% endif %}
          {% endfor %}
          
          {{ card_list | to_yaml }}