title: Homelab
views:

  # ========================================================
  # TAB 1: OVERVIEW — calendar + kuma summary + quick launch
  # ========================================================
  - type: sections
    title: Overview
    path: homelab
    icon: mdi:view-dashboard
    max_columns: 3
    sections:

      # ---- Calendar (Baikal + Radarr) ----
      - type: grid
        column_span: 2
        cards:
          - type: heading
            icon: mdi:calendar-month
            heading: Calendar
            heading_style: title

          - type: custom:calendar-card-pro
            entities:
              - entity: calendar.vish
                color: "#a78bfa"
              - entity: calendar.radarr
                color: "#f59e0b"
            days_to_show: 14
            max_events_to_show: 20
            show_past_events: false
            compact_mode: false

      # ---- Kuma summary ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:heart-pulse
            heading: Uptime Kuma
            heading_style: title

          - type: custom:mushroom-template-card
            primary: >-
              {{ states.sensor | selectattr('entity_id','match','^sensor\..*_status$') | list | count }}
            secondary: Total Monitors
            icon: mdi:pulse
            icon_color: blue
            tap_action:
              action: url
              url_path: http://100.77.151.40:3001

          - type: custom:mushroom-template-card
            primary: >-
              {{ states.sensor | selectattr('entity_id','match','^sensor\..*_status$')
                 | rejectattr('state','eq','up')
                 | rejectattr('state','eq','unavailable')
                 | rejectattr('state','eq','unknown')
                 | list | count }}
            secondary: Down / Degraded
            icon: mdi:alert-circle
            icon_color: red

          - type: custom:mushroom-template-card
            primary: >-
              {% set rts = states.sensor | selectattr('entity_id','match','^sensor\..*_response_time$')
                           | map(attribute='state') | reject('in',['unavailable','unknown','none'])
                           | map('float',0) | reject('le',0) | list %}
              {{ (rts | sum / (rts | count | max(1)) ) | round(0) }}
            secondary: Avg Response (ms)
            icon: mdi:speedometer
            icon_color: green

      # ---- Library totals ----
      - type: grid
        column_span: 3
        cards:
          - type: heading
            icon: mdi:library
            heading: Library Totals
            heading_style: title

          - type: grid
            columns: 5
            square: false
            cards:
              - type: tile
                entity: sensor.atlantis_library_movies
                name: Movies
                icon: mdi:movie-open
              - type: tile
                entity: sensor.atlantis_library_tv_shows
                name: TV Shows
                icon: mdi:television-classic
              - type: tile
                entity: sensor.atlantis_library_anime
                name: Anime
                icon: mdi:sword-cross
              - type: tile
                entity: sensor.atlantis_library_music
                name: Music
                icon: mdi:music
              - type: tile
                entity: sensor.audiobookshelf_ebooks
                name: Ebooks
                icon: mdi:book-open-variant

      # ---- Quick launch ----
      - type: grid
        column_span: 3
        cards:
          - type: heading
            icon: mdi:rocket-launch
            heading: Quick Launch
            heading_style: title

          - type: grid
            columns: 6
            square: true
            cards:
              - type: button
                name: Plex
                icon: mdi:plex
                tap_action: {action: url, url_path: https://app.plex.tv}
              - type: button
                name: Sonarr
                icon: mdi:television-classic
                tap_action: {action: url, url_path: http://100.83.230.112:8989}
              - type: button
                name: Radarr
                icon: mdi:filmstrip
                tap_action: {action: url, url_path: http://100.83.230.112:7878}
              - type: button
                name: Bazarr
                icon: mdi:subtitles
                tap_action: {action: url, url_path: http://100.83.230.112:6767}
              - type: button
                name: Prowlarr
                icon: mdi:magnify
                tap_action: {action: url, url_path: http://100.83.230.112:9696}
              - type: button
                name: SABnzbd
                icon: mdi:download
                tap_action: {action: url, url_path: http://100.83.230.112:8080}
              - type: button
                name: LazyLib
                icon: mdi:book-clock
                tap_action: {action: url, url_path: http://100.83.230.112:5299}
              - type: button
                name: ABS
                icon: mdi:headphones
                tap_action: {action: url, url_path: http://100.83.230.112:13378}
              - type: button
                name: Portainer
                icon: mdi:docker
                tap_action: {action: url, url_path: https://pt.vish.gg}
              - type: button
                name: Gitea
                icon: mdi:git
                tap_action: {action: url, url_path: https://git.vish.gg}
              - type: button
                name: Homarr
                icon: mdi:view-dashboard
                tap_action: {action: url, url_path: https://homarr.vish.gg}
              - type: button
                name: Kuma
                icon: mdi:heart-pulse
                tap_action: {action: url, url_path: http://100.77.151.40:3001}

  # ========================================================
  # TAB 2: MEDIA — Plex, *arr, downloads, books
  # ========================================================
  - type: sections
    title: Media
    path: media
    icon: mdi:play-circle
    max_columns: 3
    sections:

      # ---- Plex ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:plex
            heading: Plex
            heading_style: title

          - type: tile
            entity: sensor.atlantis
            name: Now Playing
            icon: mdi:plex
            tap_action:
              action: more-info

          - type: horizontal-stack
            cards:
              - type: tile
                entity: sensor.atlantis_library_movies
                name: Movies
                icon: mdi:movie-open
              - type: tile
                entity: sensor.atlantis_library_tv_shows
                name: TV
                icon: mdi:television-classic

          - type: horizontal-stack
            cards:
              - type: tile
                entity: sensor.atlantis_library_anime
                name: Anime
                icon: mdi:sword-cross
              - type: tile
                entity: sensor.atlantis_library_music
                name: Music
                icon: mdi:music

      # ---- Sonarr + Radarr ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:television-classic
            heading: Sonarr + Radarr
            heading_style: title

          - type: horizontal-stack
            cards:
              - type: tile
                entity: sensor.sonarr_queue_2
                name: Sonarr Q
                icon: mdi:television-classic
                tap_action: {action: url, url_path: http://100.83.230.112:8989}
              - type: tile
                entity: sensor.radarr_queue_2
                name: Radarr Q
                icon: mdi:filmstrip
                tap_action: {action: url, url_path: http://100.83.230.112:7878}

          - type: horizontal-stack
            cards:
              - type: tile
                entity: sensor.sonarr_shows
                name: Shows
                icon: mdi:television-box
              - type: tile
                entity: sensor.radarr_movies_2
                name: Movies
                icon: mdi:movie-open

          - type: horizontal-stack
            cards:
              - type: tile
                entity: sensor.sonarr_upcoming
                name: Upcoming
                icon: mdi:calendar-clock
              - type: tile
                entity: sensor.sonarr_wanted
                name: Wanted
                icon: mdi:television-off

          - type: horizontal-stack
            cards:
              - type: tile
                entity: sensor.bazarr_badges
                name: Bazarr
                icon: mdi:subtitles
                tap_action: {action: url, url_path: http://100.83.230.112:6767}
              - type: tile
                entity: sensor.prowlarr_indexers
                name: Prowlarr
                icon: mdi:magnify
                tap_action: {action: url, url_path: http://100.83.230.112:9696}

      # ---- Books ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:book-open-page-variant
            heading: Books & Audiobooks
            heading_style: title

          - type: tile
            entity: sensor.audiobookshelf_ebooks
            name: Ebooks
            icon: mdi:book-open-variant
            tap_action: {action: url, url_path: http://100.83.230.112:13378}

          - type: tile
            entity: sensor.audiobookshelf_audiobooks
            name: Audiobooks
            icon: mdi:headphones

          - type: tile
            entity: sensor.lazylibrarian_wanted_books
            name: LazyLib Wanted
            icon: mdi:book-clock
            tap_action: {action: url, url_path: http://100.83.230.112:5299}

          - type: tile
            entity: sensor.lazylibrarian_version
            name: LazyLib Version
            icon: mdi:tag

      # ---- Downloads (SABnzbd) ----
      - type: grid
        column_span: 3
        cards:
          - type: heading
            icon: mdi:download
            heading: Downloads — SABnzbd
            heading_style: title

          - type: grid
            columns: 3
            square: false
            cards:
              - type: tile
                entity: sensor.sabnzbd_speed
                name: Speed
                icon: mdi:download-network
                tap_action: {action: url, url_path: http://100.83.230.112:8080}
              - type: tile
                entity: sensor.sabnzbd_queue
                name: Queue
                icon: mdi:tray-full
              - type: tile
                entity: sensor.sabnzbd_status
                name: Status
                icon: mdi:information-outline

          - type: entities
            title: Details
            show_header_toggle: false
            entities:
              - entity: sensor.sabnzbd_left_to_download
              - entity: sensor.sabnzbd_queue_count
              - entity: sensor.sabnzbd_free_disk_space
              - entity: sensor.sabnzbd_daily_total
              - entity: sensor.sabnzbd_weekly_total
              - entity: sensor.sabnzbd_monthly_total

          - type: horizontal-stack
            cards:
              - type: button
                entity: button.sabnzbd_pause
                name: Pause
                icon: mdi:pause
                tap_action:
                  action: call-service
                  service: button.press
                  target:
                    entity_id: button.sabnzbd_pause
              - type: button
                entity: button.sabnzbd_resume
                name: Resume
                icon: mdi:play
                tap_action:
                  action: call-service
                  service: button.press
                  target:
                    entity_id: button.sabnzbd_resume

  # ========================================================
  # TAB 3: SERVERS — NASes + Proxmox + TrueNAS
  # ========================================================
  - type: sections
    title: Servers
    path: servers
    icon: mdi:server-network
    max_columns: 3
    sections:

      # ---- Atlantis NAS (Synology) ----
      - type: grid
        column_span: 2
        cards:
          - type: heading
            icon: mdi:nas
            heading: Atlantis NAS (Synology)
            heading_style: title

          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.atlantis_cpu_utilization_total
                name: CPU
                min: 0
                max: 100
                unit: "%"
                severity: {green: 0, yellow: 60, red: 85}
              - type: gauge
                entity: sensor.atlantis_memory_usage_real
                name: Memory
                min: 0
                max: 100
                unit: "%"
                severity: {green: 0, yellow: 70, red: 90}
              - type: gauge
                entity: sensor.atlantis_temperature
                name: Temp °F
                min: 60
                max: 180
                severity: {green: 60, yellow: 140, red: 160}

          - type: entities
            title: Volumes
            show_header_toggle: false
            entities:
              - {entity: sensor.atlantis_volume_1_volume_used, name: Volume 1}
              - {entity: sensor.atlantis_volume_2_volume_used, name: Volume 2}
              - {entity: sensor.atlantis_volume_3_volume_used, name: Volume 3}
              - {entity: sensor.atlantis_volume_1_used_space, name: V1 Used (TB)}
              - {entity: sensor.atlantis_volume_1_status, name: V1 Health}

          - type: horizontal-stack
            cards:
              - type: tile
                entity: sensor.atlantis_download_throughput
                name: ↓ Download
                icon: mdi:download
              - type: tile
                entity: sensor.atlantis_upload_throughput
                name: ↑ Upload
                icon: mdi:upload

          - type: entities
            title: Drive Temperatures (°F)
            show_header_toggle: false
            entities:
              - {entity: sensor.atlantis_drive_1_temperature, name: Drive 1}
              - {entity: sensor.atlantis_drive_2_temperature, name: Drive 2}
              - {entity: sensor.atlantis_drive_3_temperature, name: Drive 3}
              - {entity: sensor.atlantis_drive_4_temperature, name: Drive 4}
              - {entity: sensor.atlantis_drive_5_temperature, name: Drive 5}
              - {entity: sensor.atlantis_drive_6_temperature, name: Drive 6}
              - {entity: sensor.atlantis_drive_7_temperature, name: Drive 7}
              - {entity: sensor.atlantis_drive_8_temperature, name: Drive 8}
              - {entity: sensor.atlantis_m_2_drive_1_temperature, name: NVMe 1}
              - {entity: sensor.atlantis_m_2_drive_2_temperature, name: NVMe 2}

          - type: conditional
            conditions:
              - condition: state
                entity: update.atlantis_dsm_update
                state: "on"
            card:
              type: tile
              entity: update.atlantis_dsm_update
              name: ⚠ DSM Update Available

      # ---- Calypso NAS (compact) ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:nas
            heading: Calypso NAS
            heading_style: title

          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.calypso_cpu_utilization_total
                name: CPU
                min: 0
                max: 100
                unit: "%"
                severity: {green: 0, yellow: 60, red: 85}
              - type: gauge
                entity: sensor.calypso_memory_usage_real
                name: Mem
                min: 0
                max: 100
                unit: "%"
                severity: {green: 0, yellow: 70, red: 90}

          - type: entities
            title: Volume & Drives
            show_header_toggle: false
            entities:
              - {entity: sensor.calypso_volume_1_volume_used, name: Volume 1 %}
              - {entity: sensor.calypso_volume_1_used_space, name: V1 Used (TB)}
              - {entity: sensor.calypso_volume_1_status, name: V1 Health}
              - {entity: sensor.calypso_drive_1_temperature, name: Drive 1 Temp}
              - {entity: sensor.calypso_drive_2_temperature, name: Drive 2 Temp}
              - {entity: sensor.calypso_m_2_drive_1_temperature, name: NVMe 1 Temp}
              - {entity: sensor.calypso_m_2_drive_2_temperature, name: NVMe 2 Temp}
              - {entity: sensor.calypso_temperature, name: System Temp}
              - {entity: binary_sensor.calypso_security_status, name: Security}

          - type: conditional
            conditions:
              - condition: state
                entity: update.calypso_dsm_update
                state: "on"
            card:
              type: tile
              entity: update.calypso_dsm_update
              name: ⚠ Calypso DSM Update

      # ---- Setillo NAS (compact) ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:nas
            heading: Setillo NAS
            heading_style: title

          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.setillo_cpu_utilization_total
                name: CPU
                min: 0
                max: 100
                unit: "%"
                severity: {green: 0, yellow: 60, red: 85}
              - type: gauge
                entity: sensor.setillo_memory_usage_real
                name: Mem
                min: 0
                max: 100
                unit: "%"
                severity: {green: 0, yellow: 70, red: 90}

          - type: entities
            title: Volume & Drives
            show_header_toggle: false
            entities:
              - {entity: sensor.setillo_volume_1_volume_used, name: Volume 1 %}
              - {entity: sensor.setillo_volume_1_used_space, name: V1 Used (TB)}
              - {entity: sensor.setillo_volume_1_status, name: V1 Health}
              - {entity: sensor.setillo_drive_1_temperature, name: Drive 1 Temp}
              - {entity: sensor.setillo_drive_2_temperature, name: Drive 2 Temp}
              - {entity: sensor.setillo_temperature, name: System Temp}
              - {entity: binary_sensor.setillo_security_status, name: Security}
              - {entity: switch.setillo_surveillance_station_home_mode, name: Surveillance Home Mode}

          - type: conditional
            conditions:
              - condition: state
                entity: update.setillo_dsm_update
                state: "on"
            card:
              type: tile
              entity: update.setillo_dsm_update
              name: ⚠ Setillo DSM Update

      # ---- Guava TrueNAS ----
      - type: grid
        column_span: 2
        cards:
          - type: heading
            icon: mdi:harddisk
            heading: Guava (TrueNAS Scale)
            heading_style: title

          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.guava_system_cpu_usage
                name: CPU
                min: 0
                max: 100
                unit: "%"
                severity: {green: 0, yellow: 60, red: 85}
              - type: gauge
                entity: sensor.guava_system_memory_usage
                name: Memory
                min: 0
                max: 100
                unit: "%"
                severity: {green: 0, yellow: 70, red: 90}
              - type: tile
                entity: sensor.guava_system_temperature
                name: Temp
                icon: mdi:thermometer

          - type: entities
            title: Pool Health
            show_header_toggle: false
            entities:
              - {entity: binary_sensor.guava_system_data_healthy, name: Data Pool}
              - {entity: binary_sensor.guava_system_boot_pool_healthy, name: Boot Pool}
              - {entity: sensor.guava_system_data_free, name: Data Pool Free}
              - {entity: sensor.guava_system_boot_pool_free, name: Boot Pool Free}
              - {entity: sensor.guava_system_arc_size, name: ZFS ARC Size}
              - {entity: sensor.guava_system_uptime, name: Uptime}

          - type: entities
            title: Services + VM
            show_header_toggle: false
            entities:
              - {entity: binary_sensor.guava_services_nfs, name: NFS}
              - {entity: binary_sensor.guava_services_cifs, name: SMB/CIFS}
              - {entity: binary_sensor.guava_services_ssh, name: SSH}
              - {entity: binary_sensor.guava_services_smartd, name: SMART Daemon}
              - {entity: binary_sensor.guava_services_snmp, name: SNMP}
              - {entity: binary_sensor.guava_services_ups, name: UPS}
              - {entity: binary_sensor.guava_vms_proton_bridge, name: Proton Bridge VM}

          - type: entities
            title: Disks (SMART)
            show_header_toggle: false
            entities:
              - {entity: sensor.guava_disks_nvme0n1, name: NVMe (boot)}
              - {entity: sensor.guava_disks_sda, name: Disk sda}
              - {entity: sensor.guava_disks_sdb, name: Disk sdb}

          - type: conditional
            conditions:
              - condition: state
                entity: update.guava_system
                state: "on"
            card:
              type: tile
              entity: update.guava_system
              name: ⚠ Guava TrueNAS Update

      # ---- Proxmox VE ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:server-network
            heading: Proxmox VE
            heading_style: title

          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.pve_cpu_usage
                name: CPU
                min: 0
                max: 100
                severity: {green: 0, yellow: 60, red: 85}
              - type: gauge
                entity: sensor.pve_memory_usage_percentage
                name: Mem
                min: 0
                max: 100
                severity: {green: 0, yellow: 70, red: 90}

          - type: entities
            title: PVE Host
            show_header_toggle: false
            entities:
              - {entity: binary_sensor.pve_status, name: Status}
              - {entity: sensor.pve_uptime, name: Uptime}
              - {entity: sensor.pve_memory_usage, name: Memory Used}
              - {entity: sensor.pve_disk_usage, name: Disk Used}
              - {entity: binary_sensor.pve_backup_status, name: Backup Status}
              - {entity: sensor.pve_last_backup, name: Last Backup}

          - type: horizontal-stack
            cards:
              - type: button
                entity: button.pve_start_all
                name: Start All
                icon: mdi:play-circle
                tap_action:
                  action: call-service
                  service: button.press
                  target:
                    entity_id: button.pve_start_all
              - type: button
                entity: button.pve_stop_all
                name: Stop All
                icon: mdi:stop-circle
                tap_action:
                  action: call-service
                  service: button.press
                  target:
                    entity_id: button.pve_stop_all
              - type: button
                entity: button.pve_restart
                name: Restart
                icon: mdi:restart
                tap_action:
                  action: call-service
                  service: button.press
                  target:
                    entity_id: button.pve_restart
                confirmation:
                  text: "Restart PVE host?"

  # ========================================================
  # TAB 4: MONITORING — Kuma detail + service pings
  # ========================================================
  - type: sections
    title: Monitoring
    path: monitoring
    icon: mdi:heart-pulse
    max_columns: 2
    sections:

      # ---- Summary chips (same as Overview) ----
      - type: grid
        column_span: 2
        cards:
          - type: heading
            icon: mdi:heart-pulse
            heading: Uptime Kuma — Live
            heading_style: title

          - type: horizontal-stack
            cards:
              - type: custom:mushroom-template-card
                primary: >-
                  {{ states.sensor | selectattr('entity_id','match','^sensor\..*_status$') | list | count }}
                secondary: Total Monitors
                icon: mdi:pulse
                icon_color: blue
                tap_action:
                  action: url
                  url_path: http://100.77.151.40:3001
              - type: custom:mushroom-template-card
                primary: >-
                  {{ states.sensor | selectattr('entity_id','match','^sensor\..*_status$')
                     | rejectattr('state','eq','up')
                     | rejectattr('state','eq','unavailable')
                     | rejectattr('state','eq','unknown')
                     | list | count }}
                secondary: Down
                icon: mdi:alert-circle
                icon_color: red
              - type: custom:mushroom-template-card
                primary: >-
                  {% set rts = states.sensor | selectattr('entity_id','match','^sensor\..*_response_time$')
                               | map(attribute='state') | reject('in',['unavailable','unknown','none'])
                               | map('float',0) | reject('le',0) | list %}
                  {{ (rts | sum / (rts | count | max(1)) ) | round(0) }}
                secondary: Avg Response (ms)
                icon: mdi:speedometer
                icon_color: green
              - type: custom:mushroom-template-card
                primary: >-
                  {{ states.sensor | selectattr('entity_id','match','^sensor\..*_certificate_expiry$')
                     | map(attribute='state') | map('int',999) | reject('ge',30) | list | count }}
                secondary: Certs < 30 days
                icon: mdi:certificate
                icon_color: orange

      # ---- Core infra ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:server
            heading: Core Infrastructure
            heading_style: subtitle

          - type: entities
            show_header_toggle: false
            entities:
              - {entity: sensor.atlantis_status, name: Atlantis (NAS)}
              - {entity: sensor.proxmox_nuc_status, name: Proxmox NUC}
              - {entity: sensor.home_assistant_status, name: Home Assistant}
              - {entity: sensor.authentik_status, name: Authentik SSO}
              - {entity: sensor.headscale_status, name: Headscale}
              - {entity: sensor.crowdsec_lapi_status, name: CrowdSec}
              - {entity: sensor.nginx_proxy_manager_status, name: NPM}
              - {entity: sensor.atl_portainer_status, name: Portainer}

      # ---- Apps ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:application
            heading: Apps & Services
            heading_style: subtitle

          - type: entities
            show_header_toggle: false
            entities:
              - {entity: sensor.jellyfin_status, name: Jellyfin}
              - {entity: sensor.ollama_status, name: Ollama}
              - {entity: sensor.gitea_status, name: Gitea}
              - {entity: sensor.grafana_status, name: Grafana}
              - {entity: sensor.homarr_status, name: Homarr}
              - {entity: sensor.bitwarden_status, name: Bitwarden}
              - {entity: sensor.paperless_ngx_status, name: Paperless}
              - {entity: sensor.immich_status, name: Immich}
              - {entity: sensor.seafile_status, name: Seafile}

      # ---- Certificate expiry watch ----
      - type: grid
        column_span: 2
        cards:
          - type: heading
            icon: mdi:certificate
            heading: SSL Certificates (sorted by expiry)
            heading_style: subtitle

          - type: entities
            show_header_toggle: false
            entities:
              - {entity: sensor.crista_s_website_certificate_expiry, name: crista.love}
              - {entity: sensor.gitea_certificate_expiry, name: gitea}
              - {entity: sensor.homarr_certificate_expiry, name: homarr}
              - {entity: sensor.authentik_certificate_expiry, name: authentik}
              - {entity: sensor.headscale_certificate_expiry, name: headscale}
              - {entity: sensor.ollama_certificate_expiry, name: ollama}
              - {entity: sensor.grafana_certificate_expiry, name: grafana}
              - {entity: sensor.nginx_proxy_manager_certificate_expiry, name: npm}
              - {entity: sensor.crowdsec_lapi_certificate_expiry, name: crowdsec}
              - {entity: sensor.matrix_certificate_expiry, name: matrix}
