@extends('layouts.app') @section('title', 'Sensor: ' . $sensor->device_uuid) @section('content')

{{ $sensor->name ?? 'Sensor' }}: {{ $sensor->device_uuid }}

@if($sensor->registration && $sensor->registration->is_primary) Primary @endif
{{ $sensor->gasCompany ? $sensor->gasCompany->name : 'No Company' }}
Last seen {{ $sensor->last_ping ? $sensor->last_ping->diffForHumans() : 'Never' }}
@php $statusClasses = [ 'online' => 'bg-green-100 text-green-800', 'offline' => 'bg-gray-100 text-gray-800', 'battery_low' => 'bg-yellow-100 text-yellow-800', ][$sensor->status] ?? 'bg-gray-100 text-gray-800'; @endphp {{ ucfirst(str_replace('_', ' ', $sensor->status)) }} @if(!$sensor->is_active) Inactive @endif
@if(!$sensor->registration) Register @else View Registration @endif Edit
Back to Sensors
Gas Level
{{ $sensor->last_gas_level ?? 0 }}%
@php $gasLevel = $sensor->last_gas_level ?? 0; $gasColor = $gasLevel < 20 ? 'bg-red-500' : ($gasLevel < 50 ? 'bg-yellow-500' : 'bg-green-500'); @endphp
Battery Level
{{ $sensor->battery_level ?? 0 }}%
@php $batteryLevel = $sensor->battery_level ?? 0; $batteryColor = $batteryLevel < 20 ? 'bg-red-500' : ($batteryLevel < 50 ? 'bg-yellow-500' : 'bg-green-500'); @endphp
Last Ping
{{ $sensor->last_ping ? $sensor->last_ping->diffForHumans() : 'Never' }}
{{ $sensor->last_ping ? $sensor->last_ping->format('M j, Y g:i A') : '' }}
Active Alerts
{{ $sensor->alerts->where('resolved_at', null)->count() }}
{{ $sensor->alerts->where('resolved_at', '!=', null)->count() }} resolved
{{ $sensor->alerts->count() }} total alerts

Sensor Details

QR Code

Device Information

Device UUID
{{ $sensor->device_uuid }}
QR Code
{{ $sensor->qr_code }}
Firmware Version
{{ $sensor->firmware_version ?? 'v1.0.0' }}
Device Model
{{ $sensor->model ?? 'GasGuard Pro' }}

Status

Battery Level
@php $batteryLevel = $sensor->battery_level ?? 0; $batteryColor = $batteryLevel < 20 ? 'bg-red-500' : ($batteryLevel < 50 ? 'bg-yellow-500' : 'bg-green-500'); @endphp
{{ $batteryLevel }}%
Gas Level
@php $gasLevel = $sensor->last_gas_level ?? 0; $gasColor = $gasLevel < 20 ? 'bg-red-500' : ($gasLevel < 50 ? 'bg-yellow-500' : 'bg-green-500'); @endphp
{{ $gasLevel }}%

Location

@if($sensor->latitude && $sensor->longitude)
{{ $sensor->latitude }}, {{ $sensor->longitude }} @if($sensor->location)

{{ $sensor->location }}

@endif
@else
No location data available
@endif

Registration & Status

@if($sensor->registration)
Location
{{ $sensor->registration->location_name }}
Registration Date
{{ $sensor->registration->registered_at->format('M j, Y g:i A') }}
Status
{{ $sensor->registration->is_primary ? 'Primary Sensor' : 'Secondary Sensor' }}
@else

This sensor is not registered to any user. Register it now

@endif
Last Communication
@if($sensor->last_ping) {{ $sensor->last_ping->diffForHumans() }} ({{ $sensor->last_ping->format('M j, Y g:i A') }}) @else Never @endif
Device Status
@if($sensor->is_active) Active @else Inactive @endif
Connection Status
@php $status = $sensor->status ?? 'offline'; $statusClasses = [ 'online' => 'bg-green-100 text-green-800', 'offline' => 'bg-gray-100 text-gray-800', 'battery_low' => 'bg-yellow-100 text-yellow-800', ][$status] ?? 'bg-gray-100 text-gray-800'; @endphp {{ ucfirst($status) }}

Recent Activity

    @if($sensor->logs->count() > 0) @foreach($sensor->logs->take(5) as $log)
  • Gas Level: {{ $log->gas_level }}%

    {{ $log->created_at->diffForHumans() }}

    {{ $log->created_at->format('M j, Y g:i A') }}

    {{ $log->created_at->diffForHumans() }}
  • @endforeach @else
  • No activity logs found for this sensor.
  • @endif
@endsection