@props(['device', 'controllable' => true]) @php $entities = $device->entities; $primary = $controllable ? $entities->first(fn ($e) => in_array($e->type, ['switch', 'light'], true)) : null; $on = $primary ? (data_get($primary->state?->state, 'on') === true) : false; $secondary = $primary ? $entities->reject(fn ($e) => $e->id === $primary->id) : $entities; $online = $device->isOnline(); $icon = $device->displayIcon(); @endphp
$on, 'border-line-soft bg-surface hover:border-line' => ! $on, ])>
$on, 'bg-inset text-ink-2' => ! $on, ])>
{{ $device->name }}
{{ $device->room?->name ?? __('devices.no_room') }} @if ($device->isCloud()) @endif
@if ($secondary->isNotEmpty())
@foreach ($secondary as $entity) @endforeach
@endif @if ($primary)
$on, 'text-ink-3' => ! $on])>{{ $on ? __('devices.on') : __('devices.off') }}
@endif