Fix sensor state translations (#16393)

* Fix sensor state translations

* Fix up lint/style

* Set state_index_id

* Apply fixes from StyleCI

* Wrong call

* just use a loop

* Wrong id column

* Missing fillable

* Handle sensors missing state translations

* Before making a state index

* Can't map to a state index if it doesn't exist

* Apply fixes from StyleCI

* ies5000 overflowing tinyint

* Accept state translations directly add that in the translation

* handle duplicate state names, but with different case (skip no way to work there)

* Apply fixes from StyleCI

* Fix type stuffs

---------

Co-authored-by: Tony Murray <[email protected]>
This commit is contained in:
Tony Murray
2024-09-15 02:13:11 +02:00
committed by GitHub
co-authored by Tony Murray
parent 47cd0e75de
commit 7d450345df
8 changed files with 174 additions and 101 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
class SensorToStateIndex extends Model
{
protected $table = 'sensors_to_state_indexes';
protected $primaryKey = 'sensors_to_state_translations_id';
public $timestamps = false;
protected $fillable = ['sensor_id', 'state_index_id'];
public function sensor(): HasOne
{
return $this->hasOne(Sensor::class, 'sensor_id', 'sensor_id');
}
public function stateIndex(): HasOne
{
return $this->hasOne(StateIndex::class, 'state_index_id', 'state_index_id');
}
}