- type: custom:mod-card
  style:
    layout-card:
      $:
        .: |
          #columns {
            padding: 0 10px;
          }
          #columns .column {
            padding: 0 10px;
          }
  card:
    type: custom:layout-card
    layout: horizontal
    max_columns: 3
    cards:
      # Column 1
      - type: vertical-stack
        cards:
          - type: vertical-stack
            title: Lights
            cards:
              - type: horizontal-stack
                cards:
                  - type: custom:button-card
                    template: half
                    icon: none
                    entity: light.all
                    name: All
                  - type: custom:button-card
                    template: half
                    icon: none
                    entity: light.ceiling
                    name: Ceiling
              - type: horizontal-stack
                cards:
                  - type: custom:button-card
                    template: default
                    entity: light.living_room
                    name: Living room
                  - type: custom:button-card
                    template: default
                    entity: light.living_room_main
                    name: Main
                  - type: custom:button-card
                    template: default
                    entity: light.pc
                  - type: custom:button-card
                    template: default
                    entity: light.living_room_ambient
                    name: Ambient
              - type: horizontal-stack
                cards:
                  - type: custom:button-card
                    template: default
                    entity: light.master_bedroom
                    name: Bedroom
                  - type: custom:button-card
                    template: default
                    entity: light.master_bedroom_main
                    name: Main
                  - type: custom:button-card
                    template: default
                    entity: light.bed_led
                    name: Bed
                    tap_action:
                      action: call-service
                      service: script.bed_led_toggle
                  - type: custom:button-card
                    template: default
                    entity: light.bedside
                    name: Bedside
              - type: horizontal-stack
                cards:
                  - type: custom:button-card
                    template: default
                    entity: light.kitchen
                    name: Kitchen
                  - type: custom:button-card
                    template: default
                    entity: light.hallway_main
                    name: Hallway
                  - type: custom:button-card
                    template: default
                    entity: light.hallway_entrance
                    name: Entrance

          - type: vertical-stack
            title: Devices
            cards:
              - type: horizontal-stack
                cards:
                  - type: custom:button-card
                    template: regular
                    entity: media_player.living_room_tv
                    name: TV
                    icon: mdi:television
                    tap_action:
                      action: toggle
                    state:
                      - value: 'playing'
                        styles: &on_styles
                          card:
                            - background-color: var(--primary-color)
                            - color: black
                          icon:
                            - color: black
                      - value: 'standby'
                        styles: *on_styles
                      - value: 'on'
                        styles: *on_styles
                      - value: 'home'
                        styles: *on_styles
                      - value: 'idle'
                        styles: *on_styles

                  - type: custom:button-card
                    template: [default, with_state_indicator]
                    entity: switch.titanium
                    variables:
                      state_indicator_id: automation.titanium_turn_off_when_idle

                  - type: custom:button-card
                    template: default
                    entity: binary_sensor.pi_hole_enabled
                    name: Pi-Hole
                    icon: mdi:pi-hole

              - type: horizontal-stack
                cards:
                  - type: custom:button-card
                    template: ac_button
                  - type: custom:button-card
                    template: radiator_button
                    entity: climate.living_room_radiator_mode
                    name: "Living room"
                  - type: custom:button-card
                    template: radiator_button
                    entity: climate.bedroom_radiator_mode
                    name: "Bedroom"
                  - type: custom:button-card
                    template: radiator_button
                    entity: climate.kitchen_radiator_mode
                    name: "Kitchen"
              - type: horizontal-stack
                cards:
                  - type: custom:button-card
                    template: default
                    entity: camera.mercury_amcrest_1
                    name: Living Room
                  - type: custom:button-card
                    template: default
                    entity: camera.mercury_bedroom
                    name: Bedroom
                  - type: custom:button-card
                    template: [default, with_state_indicator]
                    entity: fan.philips_airpurifier
                    variables:
                      state_indicator_id: binary_sensor.purifier_filter_needs_change
                      state_indicator_size: 5px
                      state_indicator_off_size: 0px
                      state_indicator_on_color: var(--color-red)
                      state_on_indicator_on_color: var(--color-red)
                  - type: custom:button-card
                    template: default
                    entity: vacuum.vacuum
                    name: Vacuum
                  - type: custom:button-card
                    template: brita_water

      # Column 2
      - type: vertical-stack
        cards:
          - type: horizontal-stack
            title: Manual controls
            cards:
              - type: custom:button-card
                template: [small, with_state_indicator, with_state_background]
                entity: input_boolean.alarm_enabled
                state_display: >-
                  [[[
                    const time = states['input_datetime.alarm_time'].state;
                    return time.split(':').slice(0, -1).join(':');
                  ]]]
                show_state: true
                show_name: false
                styles:
                  icon:
                    - transform: translateY(0)  # adjusted for state indicator size
                  state:
                    - transform: translateY(-4px)  # adjusted for state indicator size
                variables:
                  state_indicator_id: automation.alarm_set_time
              - type: custom:button-card
                template: [small, with_state_background]
                entity: input_boolean.speech_notifications
                name: Speech
              - type: custom:button-card
                template: [small, with_state_background]
                entity: binary_sensor.house_mode
                name: House
                tap_action:
                  action: call-service
                  service: input_select.select_next
                  service_data:
                    entity_id: input_select.house_mode
              - type: custom:button-card
                template: [small, with_state_background]
                name: Guests
                entity: input_boolean.guest_mode
              - type: custom:button-card
                template: [small, with_state_background]
                entity: input_boolean.simulation_mode
                name: Simulation
              - type: custom:button-card
                template: [small, with_state_background]
                entity: switch.mercury_home_mode
                name: Mercury

          - type: vertical-stack
            cards:
              - type: vertical-stack
                title: Sensors
                cards:
                  - type: horizontal-stack
                    cards:
                      - type: custom:button-card
                        template: [default, cover]
                        entity: cover.living_room
                        name: LR Cover
                        tap_action:
                          action: call-service
                          service: script.toggle_living_room_cover
                      - type: custom:button-card
                        template: default
                        entity: binary_sensor.multisensor_motion
                        name: Living room
                      - type: custom:button-card
                        template: [default, with_state_indicator]
                        entity: binary_sensor.kitchen_motion_occupancy
                        name: Kitchen
                        variables:
                          state_indicator_id: automation.lighting_kitchen_motion_on
                      - type: custom:button-card
                        template: [default, with_state_indicator]
                        entity: group.hallway_motion
                        name: Hallway
                        variables:
                          state_indicator_id: automation.lighting_hallway_motion_on
                  - type: horizontal-stack
                    cards:
                      - type: custom:button-card
                        template: default
                        entity: binary_sensor.living_room_right_window
                        name: Living room
                      - type: custom:button-card
                        template: default
                        entity: binary_sensor.bedroom_left_window
                        name: Bedroom left
                      - type: custom:button-card
                        template: default
                        entity: binary_sensor.bedroom_right_window
                        name: Bedroom right
                      - type: custom:button-card
                        template: default
                        entity: binary_sensor.kitchen_window
                        name: Kitchen
                  - type: horizontal-stack
                    cards:
                      - type: custom:button-card
                        template: default
                        entity: binary_sensor.georgi_home
                        tap_action:
                          action: call-service
                          service: input_boolean.toggle
                          service_data:
                            entity_id: input_boolean.georgi_home
                      - type: custom:button-card
                        template: default
                        entity: binary_sensor.front_door
                      - type: custom:button-card
                        template: default
                        entity: binary_sensor.bedroom_door
          - type: vertical-stack
            title: Climate
            cards:
              - type: horizontal-stack
                cards:
                  - type: custom:button-card
                    template: [regular, progress]
                    entity: sensor.average_temperature
                    icon: mdi:thermometer
                    state_display: "[[[ return Math.round(entity.state) + ' °C' ]]]"
                  - type: custom:button-card
                    template: [regular, progress]
                    entity: sensor.average_humidity
                    icon: mdi:water-percent
                    state_display: "[[[ return Math.round(entity.state) + ' %' ]]]"
                    variables:
                      min_value: 25
                      max_value: 90
                      normal_value: 40
                      high_value: 65
                      low_color: "var(--color-red)"

      # Column 3
      - type: vertical-stack
        cards:
          - type: vertical-stack
            cards:
              - type: custom:decluttering-card
                template: media_with_controls
                variables:
                  - player: media_player.master_bedroom
                  - player_name: Bedroom

              - type: custom:decluttering-card
                template: sonos_media_player_small
                variables:
                  - player: media_player.living_room
                  - name: Living room

              - type: custom:decluttering-card
                template: sonos_media_player_small
                variables:
                  - player: media_player.kitchen
                  - name: Kitchen

              - type: custom:decluttering-card
                template: sonos_media_player_small
                variables:
                  - player: media_player.bathroom
                  - name: Bathroom
