mercury_card:
  default:
    - title:
    - icon:
  card:
    type: entities
    style: |
      #states > div:last-child {
        margin: 0 -16px -16px -16px;
      }
    title: "[[title]]"
    icon: "[[icon]]"
    entities:
      - type: custom:hui-horizontal-stack-card
        cards:
          - type: custom:button-card
            template: v3_xs_button
            entity: switch.cadmium
            icon: mdi:firefox
            name: "Open UI"
            tap_action:
              action: url
              url_path: https://home.gar.dev
          - type: custom:button-card
            template: v3_xs_button
            entity: update.mercury_dsm_update
            name: Update?
          - type: custom:button-card
            template: v3_xs_button
            entity: button.mercury_reboot
            name: Reboot
          - type: custom:button-card
            template: v3_xs_button
            entity: button.mercury_shutdown
            name: Shutdown

      - entity: sensor.mercury_temperature
        name: Temperature
      - type: custom:fold-entity-row
        head:
          type: custom:decluttering-card
          template: percentage_card
          variables:
            - name: CPU
            - entity: sensor.mercury_cpu_utilization_total
            - icon: mdi:chip
            - orange: 40
            - red: 60
        entities:
          - entity: sensor.mercury_cpu_utilization_user
            name: CPU load (User)
          - entity: sensor.mercury_cpu_load_average_5_min
            name: CPU load (5 min)
          - entity: sensor.mercury_cpu_load_average_15_min
            name: CPU load (15 min)

      - type: custom:fold-entity-row
        head:
          type: custom:decluttering-card
          template: percentage_card
          variables:
            - name: Memory
            - entity: sensor.mercury_memory_usage_real
            - icon: mdi:memory
            - orange: 70
            - red: 85
        entities:
          - entity: sensor.mercury_memory_available_real
            name: Memory available (Real)
          - entity: sensor.mercury_memory_total_real
            name: Memory total (Real)
          - entity: sensor.mercury_memory_available_swap
            name: Memory available (Swap)
          - entity: sensor.mercury_memory_total_swap
            name: Memory total (Swap)

      - type: custom:fold-entity-row
        head:
          type: custom:decluttering-card
          template: percentage_card
          variables:
            - name: Volume 1
            - entity: sensor.mercury_volume_1_volume_used
            - icon: mdi:harddisk
            - orange: 85
            - red: 90
        entities:
          - entity: sensor.mercury_volume_1_status
            name: Status
          - entity: sensor.mercury_volume_1_average_disk_temp
            name: Average temperature
          - entity: sensor.mercury_volume_1_used_space
            name: Used space

      - type: custom:fold-entity-row
        head:
          entity: sensor.mercury_drive_1_status
          name: Drive 1
        entities:
          - entity: sensor.mercury_drive_1_temperature
            name: Temperature
          - entity: binary_sensor.mercury_drive_1_below_min_remaining_life
            name: Below minimum remaining life
          - entity: binary_sensor.mercury_drive_1_exceeded_max_bad_sectors
            name: Exceeded max bad sectors
      - type: custom:fold-entity-row
        head:
          entity: sensor.mercury_drive_2_status
          name: Drive 2
        entities:
          - entity: sensor.mercury_drive_2_temperature
            name: Temperature
          - entity: binary_sensor.mercury_drive_2_below_min_remaining_life
            name: Below minimum remaining life
          - entity: binary_sensor.mercury_drive_2_exceeded_max_bad_sectors
            name: Exceeded max bad sectors
      - type: custom:fold-entity-row
        head:
          entity: sensor.mercury_drive_3_status
          name: Drive 3
        entities:
          - entity: sensor.mercury_drive_3_temperature
            name: Temperature
          - entity: binary_sensor.mercury_drive_3_below_min_remaining_life
            name: Below minimum remaining life
          - entity: binary_sensor.mercury_drive_3_exceeded_max_bad_sectors
            name: Exceeded max bad sectors
      - type: custom:fold-entity-row
        head:
          entity: sensor.mercury_drive_4_status
          name: Drive 4
        entities:
          - entity: sensor.mercury_drive_4_temperature
            name: Temperature
          - entity: binary_sensor.mercury_drive_4_below_min_remaining_life
            name: Below minimum remaining life
          - entity: binary_sensor.mercury_drive_4_exceeded_max_bad_sectors
            name: Exceeded max bad sectors

      - type: custom:fold-entity-row
        head:
          entity: sensor.mercury_cache_device_1_status
          name: Cache
        entities:
          - entity: sensor.mercury_cache_device_1_temperature
            name: Temperature
          - entity: binary_sensor.mercury_cache_device_1_below_min_remaining_life
            name: Below minimum remaining life
          - entity: binary_sensor.mercury_cache_device_1_exceeded_max_bad_sectors
            name: Exceeded max bad sectors

      - type: custom:hui-horizontal-stack-card
        cards:
          - type: entities
            entities:
              - entity: sensor.mercury_download_throughput
                name: Down
                style: |
                  :host {
                    --paper-item-icon-color: green;
                  }
            style: &network-indicator-style
              .: |
                ha-card {
                  box-shadow: none;
                  background: none;
                  margin-top: -1.4em;
                  max-height: 1px;
                  z-index: 2;
                }

              "#states div":
                hui-sensor-entity-row:
                  $:
                    hui-generic-entity-row:
                      $: |
                        .info {
                          margin-left: 0 !important;
                          flex-grow: 0 !important;
                          text-overflow: unset !important;
                          white-space: unset !important;
                        }
          - type: entities
            entities:
              - entity: sensor.mercury_upload_throughput
                name: Up
                style: |
                  :host {
                    --paper-item-icon-color: var(--accent-color);
                  }
            style: *network-indicator-style

      - type: custom:mini-graph-card
        align_state: left
        entities:
          - color: var(--accent-color)
            entity: sensor.mercury_upload_throughput
          - color: green
            entity: sensor.mercury_download_throughput
        group: false
        points_per_hour: 1
        line_width: 3
        hour24: true
        hours_to_show: 24
        show:
          fill: fade
          icon: false
          name: false
          state: false
          name_adaptive_color: true
          labels: hover
          legend: false
        tap_action:
          action: none
