title: Bedroom
views:
  - type: sections
    title: Bedroom
    path: bedroom
    icon: mdi:bed
    max_columns: 3
    sections:

      # ---- Lights ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:lightbulb-multiple
            heading: Lights
            heading_style: title

          - type: tile
            entity: light.vish_bedroom_light_1
            name: Light 1
            vertical: true
            features:
              - type: light-brightness
              - type: light-color-temp

          - type: tile
            entity: light.vish_bedroom_light_2
            name: Light 2
            vertical: true
            features:
              - type: light-brightness
              - type: light-color-temp

          - type: tile
            entity: light.vish_bedroom_light_3
            name: Light 3
            vertical: true
            features:
              - type: light-brightness
              - type: light-color-temp

          - type: horizontal-stack
            cards:
              - type: button
                name: All On
                icon: mdi:lightbulb-group
                tap_action:
                  action: call-service
                  service: light.turn_on
                  target:
                    entity_id:
                      - light.vish_bedroom_light_1
                      - light.vish_bedroom_light_2
                      - light.vish_bedroom_light_3
              - type: button
                name: All Off
                icon: mdi:lightbulb-group-off
                tap_action:
                  action: call-service
                  service: light.turn_off
                  target:
                    entity_id:
                      - light.vish_bedroom_light_1
                      - light.vish_bedroom_light_2
                      - light.vish_bedroom_light_3

          - type: horizontal-stack
            cards:
              - type: button
                name: Read
                icon: mdi:book-open-page-variant
                tap_action:
                  action: call-service
                  service: light.turn_on
                  data:
                    brightness_pct: 80
                    color_temp_kelvin: 3500
                  target:
                    entity_id:
                      - light.vish_bedroom_light_1
                      - light.vish_bedroom_light_2
                      - light.vish_bedroom_light_3
              - type: button
                name: Sleep
                icon: mdi:weather-night
                tap_action:
                  action: call-service
                  service: light.turn_on
                  data:
                    brightness_pct: 8
                    color_temp_kelvin: 2200
                  target:
                    entity_id:
                      - light.vish_bedroom_light_1
                      - light.vish_bedroom_light_2
                      - light.vish_bedroom_light_3

      # ---- Camera ----
      - type: grid
        column_span: 2
        cards:
          - type: heading
            icon: mdi:cctv
            heading: Bedroom Camera
            heading_style: title

          - type: picture-glance
            title: Bedroom 4K
            camera_view: live
            camera_image: camera.vish_bedroom_camera_4k_hd_stream
            entities:
              - binary_sensor.vish_bedroom_camera_4k_motion_alarm
              - binary_sensor.vish_bedroom_camera_4k_person_detection
              - switch.vish_bedroom_camera_4k_privacy
              - light.vish_bedroom_camera_4k_floodlight_timed
              - siren.vish_bedroom_camera_4k_siren

          - type: horizontal-stack
            cards:
              - type: button
                name: Up
                icon: mdi:arrow-up-bold
                tap_action:
                  action: call-service
                  service: button.press
                  target:
                    entity_id: button.vish_bedroom_camera_4k_tilt_up
              - type: button
                name: Down
                icon: mdi:arrow-down-bold
                tap_action:
                  action: call-service
                  service: button.press
                  target:
                    entity_id: button.vish_bedroom_camera_4k_tilt_down
              - type: button
                name: Left
                icon: mdi:arrow-left-bold
                tap_action:
                  action: call-service
                  service: button.press
                  target:
                    entity_id: button.vish_bedroom_camera_4k_pan_left
              - type: button
                name: Right
                icon: mdi:arrow-right-bold
                tap_action:
                  action: call-service
                  service: button.press
                  target:
                    entity_id: button.vish_bedroom_camera_4k_pan_right

          - type: heading
            icon: mdi:cctv-off
            heading: Detection
            heading_style: subtitle

          - type: grid
            columns: 2
            square: false
            cards:
              - type: tile
                entity: switch.vish_bedroom_camera_4k_motion_detection
                name: Motion
                icon: mdi:motion-sensor
                vertical: false
                tap_action:
                  action: toggle
              - type: tile
                entity: switch.vish_bedroom_camera_4k_person_detection
                name: Person
                icon: mdi:account-search
                vertical: false
                tap_action:
                  action: toggle
              - type: tile
                entity: switch.vish_bedroom_camera_4k_privacy
                name: Privacy
                icon: mdi:eye-off
                vertical: false
                tap_action:
                  action: toggle
              - type: tile
                entity: select.vish_bedroom_camera_4k_night_vision
                name: Night Vision
                icon: mdi:weather-night
                vertical: false
                tap_action:
                  action: more-info

      # ---- Media ----
      - type: grid
        column_span: 2
        cards:
          - type: heading
            icon: mdi:cast
            heading: Media
            heading_style: title

          - type: media-control
            entity: media_player.tv_bedroom
          - type: media-control
            entity: media_player.bedroom_display
          - type: media-control
            entity: media_player.spotify_vish_khemraj

      # ---- Sleep / Oura ----
      - type: grid
        column_span: 2
        cards:
          - type: heading
            icon: mdi:ring
            heading: Oura Ring
            heading_style: title

          # Hero scores
          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.oura_ring_sleep_score
                name: Sleep
                min: 0
                max: 100
                severity:
                  green: 85
                  yellow: 70
                  red: 0
                needle: true
              - type: gauge
                entity: sensor.oura_ring_readiness_score
                name: Readiness
                min: 0
                max: 100
                severity:
                  green: 85
                  yellow: 70
                  red: 0
                needle: true
              - type: gauge
                entity: sensor.oura_ring_activity_score
                name: Activity
                min: 0
                max: 100
                severity:
                  green: 85
                  yellow: 70
                  red: 0
                needle: true
              - type: gauge
                entity: sensor.oura_ring_stress_resilience_score
                name: Resilience
                min: 0
                max: 100
                severity:
                  green: 70
                  yellow: 50
                  red: 0
                needle: true

          # Sleep breakdown
          - type: entities
            title: Last Night
            show_header_toggle: false
            state_color: true
            entities:
              - entity: sensor.oura_ring_total_sleep_duration
                name: Total Sleep
                icon: mdi:bed-clock
              - entity: sensor.oura_ring_deep_sleep_duration
                name: Deep
                icon: mdi:water
              - entity: sensor.oura_ring_rem_sleep_duration
                name: REM
                icon: mdi:eye
              - entity: sensor.oura_ring_light_sleep_duration
                name: Light
                icon: mdi:weather-sunset
              - entity: sensor.oura_ring_awake_time
                name: Awake
                icon: mdi:eye-outline
              - entity: sensor.oura_ring_sleep_efficiency
                name: Efficiency
                icon: mdi:percent
              - entity: sensor.oura_ring_bedtime_start
                name: Bedtime
                icon: mdi:clock-start
              - entity: sensor.oura_ring_bedtime_end
                name: Wake
                icon: mdi:clock-end

          # Trends
          - type: history-graph
            title: Sleep & Readiness (14d)
            hours_to_show: 336
            entities:
              - entity: sensor.oura_ring_sleep_score
              - entity: sensor.oura_ring_readiness_score

          - type: history-graph
            title: HRV & Resting HR (14d)
            hours_to_show: 336
            entities:
              - entity: sensor.oura_ring_average_sleep_hrv
              - entity: sensor.oura_ring_lowest_sleep_heart_rate

          # Vitals + activity
          - type: horizontal-stack
            cards:
              - type: tile
                entity: sensor.oura_ring_average_sleep_hrv
                name: Avg HRV
                icon: mdi:heart-pulse
              - type: tile
                entity: sensor.oura_ring_lowest_sleep_heart_rate
                name: Low HR
                icon: mdi:heart
              - type: tile
                entity: sensor.oura_ring_temperature_deviation
                name: Temp Δ
                icon: mdi:thermometer
              - type: tile
                entity: sensor.oura_ring_vo2_max
                name: VO₂ Max
                icon: mdi:lungs

          - type: horizontal-stack
            cards:
              - type: tile
                entity: sensor.oura_ring_steps
                name: Steps
                icon: mdi:shoe-print
              - type: tile
                entity: sensor.oura_ring_active_calories
                name: Active Cal
                icon: mdi:fire
              - type: tile
                entity: sensor.oura_ring_cardiovascular_age
                name: CV Age
                icon: mdi:heart-cog
              - type: tile
                entity: binary_sensor.oura_ring_rest_mode
                name: Rest Mode
                icon: mdi:sleep

          - type: conditional
            conditions:
              - condition: state
                entity: sensor.oura_ring_low_battery_alert
                state: "on"
            card:
              type: tile
              entity: sensor.oura_ring_low_battery_alert
              name: Ring Battery Low
              icon: mdi:battery-alert

      # ---- Power / Environment ----
      - type: grid
        column_span: 1
        cards:
          - type: heading
            icon: mdi:flash
            heading: Guava Power
            heading_style: title

          - type: tile
            entity: switch.guava_energy
            name: Guava (TrueNAS) Plug
            icon: mdi:server-network
            vertical: true
            tap_action:
              action: toggle

          - type: entities
            show_header_toggle: false
            entities:
              - entity: sensor.guava_energy_current_consumption
                name: Power Now
              - entity: sensor.guava_energy_today_s_consumption
                name: Today
              - entity: sensor.guava_energy_this_month_s_consumption
                name: This Month
              - entity: sensor.guava_energy_voltage
                name: Voltage
              - entity: sensor.guava_energy_current
                name: Current
