mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 23:18:10 +00:00
feat: add Home Assistant example Plugin
This commit is contained in:
parent
282fdac583
commit
dfd77b392a
3 changed files with 128 additions and 0 deletions
|
|
@ -87,5 +87,24 @@ class ExampleReceiptsSeeder extends Seeder
|
||||||
'flux_icon_name' => 'calendar',
|
'flux_icon_name' => 'calendar',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Plugin::create(
|
||||||
|
[
|
||||||
|
'uuid' => '4349fdad-a273-450b-aa00-3d32f2de788d',
|
||||||
|
'name' => 'Home Assistant',
|
||||||
|
'user_id' => '1',
|
||||||
|
'data_payload' => null,
|
||||||
|
'data_stale_minutes' => 30,
|
||||||
|
'data_strategy' => 'polling',
|
||||||
|
'polling_url' => 'http://raspberrypi.local:8123/api/states',
|
||||||
|
'polling_verb' => 'get',
|
||||||
|
'polling_header' => 'Authorization: Bearer YOUR_API_KEY',
|
||||||
|
'render_markup' => null,
|
||||||
|
'render_markup_view' => 'receipts.home-assistant',
|
||||||
|
'detail_view_route' => null,
|
||||||
|
'icon_url' => null,
|
||||||
|
'flux_icon_name' => 'thermometer',
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
41
resources/views/flux/icon/thermometer.blade.php
Normal file
41
resources/views/flux/icon/thermometer.blade.php
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
{{-- Credit: Lucide (https://lucide.dev) --}}
|
||||||
|
|
||||||
|
@props([
|
||||||
|
'variant' => 'outline',
|
||||||
|
])
|
||||||
|
|
||||||
|
@php
|
||||||
|
if ($variant === 'solid') {
|
||||||
|
throw new \Exception('The "solid" variant is not supported in Lucide.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$classes = Flux::classes('shrink-0')
|
||||||
|
->add(match($variant) {
|
||||||
|
'outline' => '[:where(&)]:size-6',
|
||||||
|
'solid' => '[:where(&)]:size-6',
|
||||||
|
'mini' => '[:where(&)]:size-5',
|
||||||
|
'micro' => '[:where(&)]:size-4',
|
||||||
|
});
|
||||||
|
|
||||||
|
$strokeWidth = match ($variant) {
|
||||||
|
'outline' => 2,
|
||||||
|
'mini' => 2.25,
|
||||||
|
'micro' => 2.5,
|
||||||
|
};
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<svg
|
||||||
|
{{ $attributes->class($classes) }}
|
||||||
|
data-flux-icon
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="{{ $strokeWidth }}"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
data-slot="icon"
|
||||||
|
>
|
||||||
|
<path d="M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z" />
|
||||||
|
</svg>
|
||||||
68
resources/views/receipts/home-assistant.blade.php
Normal file
68
resources/views/receipts/home-assistant.blade.php
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
@php
|
||||||
|
$weatherEntity = collect($data)->first(function($entity) {
|
||||||
|
return $entity['entity_id'] === 'weather.forecast_home';
|
||||||
|
});
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<x-trmnl::view>
|
||||||
|
<x-trmnl::layout class="layout--col gap--space-between">
|
||||||
|
@if($weatherEntity)
|
||||||
|
|
||||||
|
<div class="grid" style="gap: 9px;">
|
||||||
|
<div class="row row--center col--span-3 col--end">
|
||||||
|
<img class="weather-image" style="max-height: 150px; margin:auto;"
|
||||||
|
src="https://usetrmnl.com/images/weather/wi-thermometer.svg">
|
||||||
|
</div>
|
||||||
|
<div class="col col--span-3 col--end">
|
||||||
|
<div class="item h--full">
|
||||||
|
<div class="meta"></div>
|
||||||
|
<div class="justify-center">
|
||||||
|
<span class="value value--xxxlarge"
|
||||||
|
data-fit-value="true">{{ $weatherEntity['attributes']['temperature'] }}</span>
|
||||||
|
<span class="label">Temperature {{ $weatherEntity['attributes']['temperature_unit'] }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col col--span-3 col--end gap--medium">
|
||||||
|
<div class="item">
|
||||||
|
<div class="meta"></div>
|
||||||
|
<div class="icon">
|
||||||
|
{{-- <img class="weather-icon" src="https://usetrmnl.com/images/weather/wi-thermometer.svg">--}}
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<span class="value value--small">{{ $weatherEntity['attributes']['wind_speed'] }} {{ $weatherEntity['attributes']['wind_speed_unit'] }}</span>
|
||||||
|
<span class="label">Wind Speed</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item">
|
||||||
|
<div class="meta"></div>
|
||||||
|
<div class="icon">
|
||||||
|
{{-- <img class="weather-icon" src="https://usetrmnl.com/images/weather/wi-raindrops.svg">--}}
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<span class="value value--small">{{ $weatherEntity['attributes']['humidity'] }}%</span>
|
||||||
|
<span class="label">Humidity</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item">
|
||||||
|
<div class="meta"></div>
|
||||||
|
<div class="icon">
|
||||||
|
{{-- <img class="weather-icon" src="https://usetrmnl.com/images/weather/wi-day-sunny.svg">--}}
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<span class="value value--xsmall">{{ Str::title($weatherEntity['state']) }}</span>
|
||||||
|
<span class="label">Right Now</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@else
|
||||||
|
<p>Weather forecast data not found.</p>
|
||||||
|
@endif
|
||||||
|
</x-trmnl::layout>
|
||||||
|
|
||||||
|
<x-trmnl::title-bar title="Home Assistant"/>
|
||||||
|
</x-trmnl::view>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue