title: Home
views:
  - type: sections
    title: Home
    path: home
    icon: mdi:home
    max_columns: 3
    sections:

      # ---- Greeting + presence ----
      - type: grid
        column_span: 3
        cards:
          - type: custom:mushroom-template-card
            primary: >-
              {% set t = now().hour %}
              {% if t < 5 %}Good night, Vish
              {% elif t < 12 %}Good morning, Vish
              {% elif t < 17 %}Good afternoon, Vish
              {% elif t < 21 %}Good evening, Vish
              {% else %}Good night, Vish{% endif %}
            secondary: >-
              {{ as_timestamp(now()) | timestamp_custom('%A, %B %-d • %-I:%M %p') }}
            icon: mdi:home-heart
            icon_color: >-
              {% set t = now().hour %}
              {% if t < 6 or t > 20 %}indigo
              {% elif t < 10 %}amber
              {% elif t < 17 %}blue
              {% else %}deep-orange{% endif %}
            tap_action:
              action: none

          - type: custom:mushroom-chips-card
            alignment: center
            chips:
              - type: entity
                entity: weather.forecast_home
                icon_color: blue
                tap_action:
                  action: more-info
              - type: entity
                entity: sensor.oura_ring_readiness_score
                name: Readiness
                icon: mdi:ring
                icon_color: green
                content_info: state
                tap_action:
                  action: more-info
              - type: entity
                entity: sensor.oura_ring_sleep_score
                name: Sleep
                icon: mdi:sleep
                icon_color: indigo
                content_info: state
              - type: entity
                entity: sensor.atlantis
                name: Plex
                icon: mdi:plex
                icon_color: orange
                content_info: state
              - type: entity
                entity: sensor.adguard_home_dns_queries_blocked_ratio
                name: AdGuard
                icon: mdi:shield-check
                icon_color: teal
                content_info: state
              - type: entity
                entity: sensor.speedtest_download
                icon: mdi:download-network
                icon_color: cyan
                content_info: state
              - type: entity
                entity: sensor.atlantis_cpu_utilization_total
                name: NAS CPU
                icon: mdi:nas
                icon_color: blue
                content_info: state
              - type: entity
                entity: sensor.pve_cpu_usage
                name: PVE CPU
                icon: mdi:server-network
                icon_color: green
                content_info: state

      # ---- Persons ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:account-multiple
            heading: People
            heading_style: title

          - type: custom:mushroom-person-card
            entity: person.vish
            layout: horizontal
            primary_info: name
            secondary_info: state
            icon_type: entity-picture
          - type: custom:mushroom-person-card
            entity: person.crista
            layout: horizontal
            primary_info: name
            secondary_info: state
            icon_type: entity-picture

      # ---- Weather hero ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:weather-partly-cloudy
            heading: Weather
            heading_style: title

          - type: weather-forecast
            entity: weather.forecast_home
            forecast_type: daily

      # ---- Oura hero ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:ring
            heading: Oura Today
            heading_style: title

          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.oura_ring_readiness_score
                name: Ready
                min: 0
                max: 100
                needle: true
                severity:
                  green: 85
                  yellow: 70
                  red: 0
              - type: gauge
                entity: sensor.oura_ring_sleep_score
                name: Sleep
                min: 0
                max: 100
                needle: true
                severity:
                  green: 85
                  yellow: 70
                  red: 0

          - type: custom:mushroom-template-card
            primary: "Slept {{ states('sensor.oura_ring_total_sleep_duration') }} hrs"
            secondary: >-
              HRV {{ states('sensor.oura_ring_average_sleep_hrv') }} •
              HR {{ states('sensor.oura_ring_lowest_sleep_heart_rate') }}
            icon: mdi:bed-clock
            icon_color: indigo

      # ---- Rooms nav ----
      - type: grid
        column_span: 3
        cards:
          - type: heading
            icon: mdi:floor-plan
            heading: Rooms
            heading_style: title

          - type: grid
            columns: 5
            square: false
            cards:
              - type: custom:mushroom-template-card
                primary: Living Room
                secondary: >-
                  {% set lights = [] %}
                  {% if states('media_player.tv_living_room') != 'off' %}TV on{% else %}{{ states('sensor.speedtest_download') }} Mbps ↓{% endif %}
                icon: mdi:sofa
                icon_color: >-
                  {% if states('media_player.tv_living_room') not in ['off','standby','unavailable'] %}deep-orange{% else %}grey{% endif %}
                tap_action:
                  action: navigate
                  navigation_path: /living-room/living-room
              - type: custom:mushroom-template-card
                primary: Kitchen
                secondary: >-
                  {% set lights = ['light.kitchen_above_sink','light.kitchen_light_1','light.kitchen_light_2','light.kitchen_light_3','light.kitchen_light_4'] %}
                  {% set on = lights | select('is_state','on') | list | count %}
                  {{ on }}/{{ lights|count }} lights on
                icon: mdi:stove
                icon_color: >-
                  {% set lights = ['light.kitchen_above_sink','light.kitchen_light_1','light.kitchen_light_2','light.kitchen_light_3','light.kitchen_light_4'] %}
                  {% set on = lights | select('is_state','on') | list | count %}
                  {% if on > 0 %}amber{% else %}grey{% endif %}
                tap_action:
                  action: navigate
                  navigation_path: /kitchen-view/kitchen
              - type: custom:mushroom-template-card
                primary: Bathroom
                secondary: >-
                  {% set lights = ['light.bathroom_light_1','light.bathroom_light_2','light.bathroom_light_3','light.bathroom_light_4','light.bathroom_light_5','light.bathroom_light_6'] %}
                  {% set on = lights | select('is_state','on') | list | count %}
                  {{ on }}/{{ lights|count }} lights on
                icon: mdi:shower
                icon_color: >-
                  {% set lights = ['light.bathroom_light_1','light.bathroom_light_2','light.bathroom_light_3','light.bathroom_light_4','light.bathroom_light_5','light.bathroom_light_6'] %}
                  {% set on = lights | select('is_state','on') | list | count %}
                  {% if on > 0 %}amber{% else %}grey{% endif %}
                tap_action:
                  action: navigate
                  navigation_path: /bathroom-view/bathroom
              - type: custom:mushroom-template-card
                primary: Bedroom
                secondary: >-
                  {% set lights = ['light.vish_bedroom_light_1','light.vish_bedroom_light_2','light.vish_bedroom_light_3'] %}
                  {% set on = lights | select('is_state','on') | list | count %}
                  {{ on }}/{{ lights|count }} • {{ states('switch.guava_energy') }} plug
                icon: mdi:bed
                icon_color: >-
                  {% set lights = ['light.vish_bedroom_light_1','light.vish_bedroom_light_2','light.vish_bedroom_light_3'] %}
                  {% set on = lights | select('is_state','on') | list | count %}
                  {% if on > 0 %}amber{% else %}purple{% endif %}
                tap_action:
                  action: navigate
                  navigation_path: /bedroom-view/bedroom
              - type: custom:mushroom-template-card
                primary: Cameras
                secondary: >-
                  {% if is_state('binary_sensor.vish_bedroom_camera_4k_motion_alarm','on') %}⚠ Motion
                  {% elif is_state('switch.vish_bedroom_camera_4k_privacy','on') %}Privacy on
                  {% else %}Armed{% endif %}
                icon: mdi:cctv
                icon_color: >-
                  {% if is_state('binary_sensor.vish_bedroom_camera_4k_motion_alarm','on') %}red
                  {% elif is_state('switch.vish_bedroom_camera_4k_privacy','on') %}grey
                  {% else %}teal{% endif %}
                tap_action:
                  action: navigate
                  navigation_path: /cameras-view/live

      # ---- Quick actions / scenes ----
      - type: grid
        column_span: 2
        cards:
          - type: heading
            icon: mdi:flash
            heading: Quick Actions
            heading_style: title

          - type: grid
            columns: 4
            square: true
            cards:
              - type: custom:mushroom-template-card
                primary: Goodnight
                icon: mdi:moon-waxing-crescent
                icon_color: indigo
                tap_action:
                  action: call-service
                  service: light.turn_off
                  data: {}
                  target:
                    entity_id:
                      - light.kitchen_above_sink
                      - light.kitchen_light_1
                      - light.kitchen_light_2
                      - light.kitchen_light_3
                      - light.kitchen_light_4
                      - light.bathroom_light_1
                      - light.bathroom_light_2
                      - light.bathroom_light_3
                      - light.bathroom_light_4
                      - light.bathroom_light_5
                      - light.bathroom_light_6
              - type: custom:mushroom-template-card
                primary: All Lights Off
                icon: mdi:lightbulb-off
                icon_color: grey
                tap_action:
                  action: call-service
                  service: light.turn_off
                  data:
                    entity_id: all
              - type: custom:mushroom-template-card
                primary: Bedtime Dim
                icon: mdi:bed
                icon_color: purple
                tap_action:
                  action: call-service
                  service: light.turn_on
                  data:
                    brightness_pct: 10
                    color_temp_kelvin: 2200
                  target:
                    entity_id:
                      - light.vish_bedroom_light_1
                      - light.vish_bedroom_light_2
                      - light.vish_bedroom_light_3
              - type: custom:mushroom-template-card
                primary: Movie Mode
                icon: mdi:movie-open
                icon_color: deep-orange
                tap_action:
                  action: call-service
                  service: light.turn_on
                  data:
                    brightness_pct: 15
                    color_temp_kelvin: 2500
                  target:
                    entity_id:
                      - light.kitchen_above_sink
                      - light.kitchen_light_1
                      - light.kitchen_light_2
                      - light.kitchen_light_3
                      - light.kitchen_light_4

      # ---- Homelab strip ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:server
            heading: Homelab
            heading_style: title

          - type: custom:mushroom-chips-card
            alignment: start
            chips:
              - type: entity
                entity: sensor.sonarr_wanted
                icon: mdi:television-classic
                icon_color: blue
                content_info: state
              - type: entity
                entity: sensor.radarr_missing
                icon: mdi:filmstrip
                icon_color: orange
                content_info: state
              - type: entity
                entity: sensor.sabnzbd_speed
                icon: mdi:download
                icon_color: cyan
                content_info: state
              - type: entity
                entity: sensor.bazarr_badges
                icon: mdi:subtitles
                icon_color: purple
                content_info: state

          - type: custom:mushroom-template-card
            primary: Library Totals
            secondary: >-
              {{ states('sensor.sonarr_shows') }} series •
              {{ states('sensor.radarr_movies_2') }} movies •
              {{ states('sensor.audiobookshelf_ebooks') }} ebooks
            icon: mdi:library-shelves
            icon_color: green
            tap_action:
              action: navigate
              navigation_path: /homelab-view/homelab
