mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
fix: compatibility with trmnl simulator
This commit is contained in:
parent
e6a2bdb3bc
commit
1983197c98
4 changed files with 32 additions and 8 deletions
|
|
@ -44,7 +44,7 @@ COPY --chown=www-data:www-data . .
|
|||
COPY --chown=www-data:www-data ./.env.example ./.env
|
||||
|
||||
# Install application dependencies
|
||||
RUN composer install --no-dev --optimize-autoloader --no-interaction
|
||||
RUN composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||
RUN npm install && npm run build
|
||||
|
||||
# Copy configuration files
|
||||
|
|
|
|||
14
README.md
14
README.md
|
|
@ -6,17 +6,22 @@ Inspired by [usetrmnl/byos_sinatra](https://github.com/usetrmnl/byos_sinatra).
|
|||
|
||||

|
||||
|
||||
[More Screenshots](screenshots/SCREENSHOTS.md)
|
||||
* 👉 [more Screenshots](screenshots/SCREENSHOTS.md)
|
||||
|
||||
### Key Features
|
||||
|
||||
* 📡 Device Information – Display battery status, WiFi strength, firmware version, and more.
|
||||
* 🔍 Auto-Join – Automatically detects and adds devices from your local network.
|
||||
* 🖥️ Screen Generation – Supports Markup, API, or update via Code.
|
||||
* 🔄 TRMNL API Proxy – Can act as a proxy for TRMNL API (requires TRMNL Developer Edition).
|
||||
* 🔄 TRMNL API Proxy – Can act as a proxy for the TRMNL Display API (requires TRMNL Developer Edition).
|
||||
* This enables a hybrid setup – for example, you can update your custom Train Monitor every 5 minutes in the morning, while displaying native TRMNL plugins throughout the day.
|
||||
* 🐳 Deployment – Dockerized setup for easier hosting (Dockerfile, docker-compose).
|
||||
|
||||
### 🎯 Target Audience
|
||||
|
||||
This project is for developers who are looking for a self-hosted server for devices running the TRMNL firmware.
|
||||
It serves as a starter kit, giving you the flexibility to build and extend it however you like.
|
||||
|
||||
### Requirements
|
||||
|
||||
* PHP >= 8.2
|
||||
|
|
@ -178,7 +183,7 @@ class PluginTrainMonitorFetch extends Command
|
|||
{
|
||||
protected $signature = 'plugin:train:fetch';
|
||||
|
||||
protected $description = 'Command description';
|
||||
protected $description = 'Fetches train monitor data and updates the screen';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
|
|
@ -239,6 +244,9 @@ Here are some features and improvements that are open for contribution:
|
|||
- 🏡 Home Assistant integration
|
||||
- Provide Web UI controls to enable/disable plugins.
|
||||
|
||||
##### 📦 Visual Studio Code Devcontainer
|
||||
* Add a .devcontainer to this repo for easier development with Docker.
|
||||
|
||||
##### Improve Code Coverage
|
||||
|
||||
- Expand Pest tests to cover more functionality.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class DeviceFactory extends Factory
|
|||
'mac_address' => $this->faker->macAddress(),
|
||||
'default_refresh_interval' => '900',
|
||||
'friendly_id' => Str::random(6),
|
||||
'api_key' => 'tD-'.Str::random(19),
|
||||
'api_key' => Str::random(22),
|
||||
'user_id' => 1,
|
||||
'last_battery_voltage' => $this->faker->randomFloat(2, 3.0, 4.2),
|
||||
'last_rssi_level' => $this->faker->numberBetween(-100, 0),
|
||||
|
|
|
|||
|
|
@ -75,12 +75,28 @@ Route::get('/setup', function (Request $request) {
|
|||
$device = Device::where('mac_address', $mac_address)->first();
|
||||
|
||||
if (! $device) {
|
||||
// Check if there's a user with assign_new_devices enabled
|
||||
$auto_assign_user = User::where('assign_new_devices', true)->first();
|
||||
|
||||
if ($auto_assign_user) {
|
||||
// Create a new device and assign it to this user
|
||||
$device = Device::create([
|
||||
'mac_address' => $mac_address,
|
||||
'api_key' => Str::random(22),
|
||||
'user_id' => $auto_assign_user->id,
|
||||
'name' => "{$auto_assign_user->name}'s TRMNL",
|
||||
'friendly_id' => Str::random(6),
|
||||
'default_refresh_interval' => 900,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => 'MAC Address not registered',
|
||||
'message' => 'MAC Address not registered or invalid access token',
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => '200',
|
||||
'api_key' => $device->api_key,
|
||||
'friendly_id' => $device->friendly_id,
|
||||
'image_url' => url('storage/images/setup-logo.png'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue