Compare commits

..

4 commits

Author SHA1 Message Date
Benjamin Nussbaum
226afa2ed3 feat(pipeline): enhance color palette support
Some checks failed
tests / ci (push) Has been cancelled
2026-02-12 22:15:34 +01:00
Benjamin Nussbaum
cb46636452 fix: remove duplicate layout in zen recipe 2026-02-12 22:02:16 +01:00
Benjamin Nussbaum
8400c1eaf1 feat(#188): support battery-percent header 2026-02-12 21:48:03 +01:00
Benjamin Nussbaum
d9ab052cbc chore: update dependencies 2026-02-12 18:06:54 +01:00
5 changed files with 72 additions and 39 deletions

View file

@ -16,7 +16,7 @@
"ext-simplexml": "*", "ext-simplexml": "*",
"ext-zip": "*", "ext-zip": "*",
"bnussbau/laravel-trmnl-blade": "2.3.*", "bnussbau/laravel-trmnl-blade": "2.3.*",
"bnussbau/trmnl-pipeline-php": "^0.6.0", "bnussbau/trmnl-pipeline-php": "0.7.*",
"keepsuit/laravel-liquid": "^0.5.2", "keepsuit/laravel-liquid": "^0.5.2",
"laravel/fortify": "^1.30", "laravel/fortify": "^1.30",
"laravel/framework": "^12.1", "laravel/framework": "^12.1",

54
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "a4438c591a5d746f546eab261e9e1efc", "content-hash": "909d7acdf3f0ace9fb6d20b4de1eeaca",
"packages": [ "packages": [
{ {
"name": "aws/aws-crt-php", "name": "aws/aws-crt-php",
@ -298,16 +298,16 @@
}, },
{ {
"name": "bnussbau/trmnl-pipeline-php", "name": "bnussbau/trmnl-pipeline-php",
"version": "0.6.0", "version": "0.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/bnussbau/trmnl-pipeline-php.git", "url": "https://github.com/bnussbau/trmnl-pipeline-php.git",
"reference": "228505afa8a39a5033916e9ae5ccbf1733092c1f" "reference": "da80de2b6456776eeabc1fb95fd42e5f3357d865"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/bnussbau/trmnl-pipeline-php/zipball/228505afa8a39a5033916e9ae5ccbf1733092c1f", "url": "https://api.github.com/repos/bnussbau/trmnl-pipeline-php/zipball/da80de2b6456776eeabc1fb95fd42e5f3357d865",
"reference": "228505afa8a39a5033916e9ae5ccbf1733092c1f", "reference": "da80de2b6456776eeabc1fb95fd42e5f3357d865",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -349,7 +349,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/bnussbau/trmnl-pipeline-php/issues", "issues": "https://github.com/bnussbau/trmnl-pipeline-php/issues",
"source": "https://github.com/bnussbau/trmnl-pipeline-php/tree/0.6.0" "source": "https://github.com/bnussbau/trmnl-pipeline-php/tree/0.7.0"
}, },
"funding": [ "funding": [
{ {
@ -357,7 +357,7 @@
"type": "buy_me_a_coffee" "type": "buy_me_a_coffee"
}, },
{ {
"url": "https://usetrmnl.com/?ref=laravel-trmnl", "url": "https://trmnl.com/?ref=laravel-trmnl",
"type": "custom" "type": "custom"
}, },
{ {
@ -365,7 +365,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2025-12-02T15:18:51+00:00" "time": "2026-02-07T22:22:18+00:00"
}, },
{ {
"name": "brick/math", "name": "brick/math",
@ -9066,16 +9066,16 @@
}, },
{ {
"name": "laravel/boost", "name": "laravel/boost",
"version": "v2.1.2", "version": "v2.1.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/boost.git", "url": "https://github.com/laravel/boost.git",
"reference": "81ecf79e82c979efd92afaeac012605cc7b2f31f" "reference": "b96e0ab547d51d3810498dcc4d5535486991df6f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/boost/zipball/81ecf79e82c979efd92afaeac012605cc7b2f31f", "url": "https://api.github.com/repos/laravel/boost/zipball/b96e0ab547d51d3810498dcc4d5535486991df6f",
"reference": "81ecf79e82c979efd92afaeac012605cc7b2f31f", "reference": "b96e0ab547d51d3810498dcc4d5535486991df6f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9086,7 +9086,7 @@
"illuminate/support": "^11.45.3|^12.41.1", "illuminate/support": "^11.45.3|^12.41.1",
"laravel/mcp": "^0.5.1", "laravel/mcp": "^0.5.1",
"laravel/prompts": "^0.3.10", "laravel/prompts": "^0.3.10",
"laravel/roster": "^0.2.9", "laravel/roster": "^0.4.0",
"php": "^8.2" "php": "^8.2"
}, },
"require-dev": { "require-dev": {
@ -9128,7 +9128,7 @@
"issues": "https://github.com/laravel/boost/issues", "issues": "https://github.com/laravel/boost/issues",
"source": "https://github.com/laravel/boost" "source": "https://github.com/laravel/boost"
}, },
"time": "2026-02-10T17:40:45+00:00" "time": "2026-02-11T19:22:04+00:00"
}, },
{ {
"name": "laravel/mcp", "name": "laravel/mcp",
@ -9352,31 +9352,31 @@
}, },
{ {
"name": "laravel/roster", "name": "laravel/roster",
"version": "v0.2.9", "version": "v0.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/roster.git", "url": "https://github.com/laravel/roster.git",
"reference": "82bbd0e2de614906811aebdf16b4305956816fa6" "reference": "77e6c1187952d0eef50a54922db47893f5e7c986"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/roster/zipball/82bbd0e2de614906811aebdf16b4305956816fa6", "url": "https://api.github.com/repos/laravel/roster/zipball/77e6c1187952d0eef50a54922db47893f5e7c986",
"reference": "82bbd0e2de614906811aebdf16b4305956816fa6", "reference": "77e6c1187952d0eef50a54922db47893f5e7c986",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/console": "^10.0|^11.0|^12.0", "illuminate/console": "^11.0|^12.0|^13.0",
"illuminate/contracts": "^10.0|^11.0|^12.0", "illuminate/contracts": "^11.0|^12.0|^13.0",
"illuminate/routing": "^10.0|^11.0|^12.0", "illuminate/routing": "^11.0|^12.0|^13.0",
"illuminate/support": "^10.0|^11.0|^12.0", "illuminate/support": "^11.0|^12.0|^13.0",
"php": "^8.1|^8.2", "php": "^8.2",
"symfony/yaml": "^6.4|^7.2" "symfony/yaml": "^7.2|^8.0"
}, },
"require-dev": { "require-dev": {
"laravel/pint": "^1.14", "laravel/pint": "^1.14",
"mockery/mockery": "^1.6", "mockery/mockery": "^1.6",
"orchestra/testbench": "^8.22.0|^9.0|^10.0", "orchestra/testbench": "^9.0|^10.0|^11.0",
"pestphp/pest": "^2.0|^3.0", "pestphp/pest": "^3.0|^4.1",
"phpstan/phpstan": "^2.0" "phpstan/phpstan": "^2.0"
}, },
"type": "library", "type": "library",
@ -9409,7 +9409,7 @@
"issues": "https://github.com/laravel/roster/issues", "issues": "https://github.com/laravel/roster/issues",
"source": "https://github.com/laravel/roster" "source": "https://github.com/laravel/roster"
}, },
"time": "2025-10-20T09:56:46+00:00" "time": "2026-02-11T07:24:41+00:00"
}, },
{ {
"name": "laravel/sail", "name": "laravel/sail",

View file

@ -1,15 +1,13 @@
{{--@dump($data)--}} {{--@dump($data)--}}
@props(['size' => 'full']) @props(['size' => 'full'])
<x-trmnl::view size="{{ $size }}"> <x-trmnl::view size="{{ $size }}">
<x-trmnl::layout> <x-trmnl::layout class="layout--col">
<x-trmnl::layout class="layout--col"> <div class="b-h-gray-1">{{$data['data'][0]['a'] ?? ''}}</div>
<div class="b-h-gray-1">{{$data['data'][0]['a'] ?? ''}}</div> @if (strlen($data['data'][0]['q'] ?? '') < 300 && $size != 'quadrant')
@if (strlen($data['data'][0]['q'] ?? '') < 300 && $size != 'quadrant') <p class="value">{{ $data['data'][0]['q'] ?? '' }}</p>
<p class="value">{{ $data['data'][0]['q'] ?? '' }}</p> @else
@else <p class="value--small">{{ $data['data'][0]['q'] ?? '' }}</p>
<p class="value--small">{{ $data['data'][0]['q'] ?? '' }}</p> @endif
@endif
</x-trmnl::layout>
</x-trmnl::layout> </x-trmnl::layout>
<div class="title_bar"> <div class="title_bar">

View file

@ -49,8 +49,9 @@ Route::get('/display', function (Request $request) {
'last_refreshed_at' => now(), 'last_refreshed_at' => now(),
]); ]);
if ($request->hasHeader('battery-percent')) { $batteryPercent = $request->header('battery-percent') ?? $request->header('percent-charged');
$batteryPercent = (int) $request->header('battery-percent'); if ($batteryPercent !== null) {
$batteryPercent = (int) $batteryPercent;
$batteryVoltage = $device->calculateVoltageFromPercent($batteryPercent); $batteryVoltage = $device->calculateVoltageFromPercent($batteryPercent);
$device->update([ $device->update([
'last_battery_voltage' => $batteryVoltage, 'last_battery_voltage' => $batteryVoltage,

View file

@ -725,6 +725,40 @@ test('display endpoint updates last_refreshed_at timestamp', function (): void {
->and($device->last_refreshed_at->diffInSeconds(now()))->toBeLessThan(2); ->and($device->last_refreshed_at->diffInSeconds(now()))->toBeLessThan(2);
}); });
test('display endpoint accepts battery-percent header and updates device', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:56',
'api_key' => 'test-api-key-battery',
'last_battery_voltage' => null,
]);
$this->withHeaders([
'id' => $device->mac_address,
'access-token' => $device->api_key,
'battery-percent' => '67',
])->get('/api/display')->assertOk();
$device->refresh();
expect($device->battery_percent)->toEqual(67);
});
test('display endpoint accepts Percent-Charged header and updates device', function (): void {
$device = Device::factory()->create([
'mac_address' => '00:11:22:33:44:57',
'api_key' => 'test-api-key-percent-charged',
'last_battery_voltage' => null,
]);
$this->withHeaders([
'id' => $device->mac_address,
'access-token' => $device->api_key,
'Percent-Charged' => '51',
])->get('/api/display')->assertOk();
$device->refresh();
expect($device->battery_percent)->toEqual(51);
});
test('display endpoint updates last_refreshed_at timestamp for mirrored devices', function (): void { test('display endpoint updates last_refreshed_at timestamp for mirrored devices', function (): void {
// Create source device // Create source device
$sourceDevice = Device::factory()->create([ $sourceDevice = Device::factory()->create([