mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: prefer temperature device (#285)
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:toolbox/core/extension/listx.dart';
|
||||
import 'package:toolbox/data/res/logger.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
|
||||
final class SensorAdaptor {
|
||||
final String raw;
|
||||
@@ -101,6 +102,22 @@ final class SensorItem {
|
||||
return items;
|
||||
}
|
||||
|
||||
static double? findPreferTempVal(List<SensorItem> items) {
|
||||
if (items.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
final preferTemperatureDevs = Stores.setting.preferTemperatureDevs.fetch();
|
||||
if (preferTemperatureDevs.isNotEmpty) {
|
||||
for (final key in preferTemperatureDevs) {
|
||||
final item = items.firstWhereOrNull((e) => e.device == key);
|
||||
if (item != null) {
|
||||
return item.props.values.firstOrNull?.current;
|
||||
}
|
||||
}
|
||||
}
|
||||
return items.first.props.values.firstOrNull?.current;
|
||||
}
|
||||
|
||||
static const sensorsRaw = '''
|
||||
{
|
||||
"coretemp-isa-0000":{
|
||||
|
||||
Reference in New Issue
Block a user