finished ac devices

This commit is contained in:
ashrafzarkanisala
2024-11-23 21:51:20 +03:00
parent 5e91d7c03a
commit 7dccfb5a76
25 changed files with 810 additions and 770 deletions

View File

@ -1,3 +1,5 @@
import 'package:flutter/material.dart';
abstract class DeviceFunction<T> {
final String deviceId;
final String deviceName;
@ -12,34 +14,33 @@ abstract class DeviceFunction<T> {
required this.operationName,
required this.icon,
});
T execute(T currentStatus, dynamic newValue);
}
class DeviceFunctionData {
final String entityId;
final String actionExecutor;
final String function;
final String functionCode;
final String operationName;
final dynamic value;
final String? condition;
final String? valueDescription;
final UniqueKey uniqueKey;
DeviceFunctionData({
required this.entityId,
this.actionExecutor = 'function',
required this.function,
this.actionExecutor = 'device_issue',
required this.functionCode,
required this.operationName,
required this.value,
this.condition,
this.valueDescription,
});
}) : uniqueKey = UniqueKey();
Map<String, dynamic> toJson() {
return {
'entityId': entityId,
'actionExecutor': actionExecutor,
'function': function,
'function': functionCode,
'operationName': operationName,
'value': value,
if (condition != null) 'condition': condition,
@ -51,7 +52,7 @@ class DeviceFunctionData {
return DeviceFunctionData(
entityId: json['entityId'],
actionExecutor: json['actionExecutor'] ?? 'function',
function: json['function'],
functionCode: json['function'],
operationName: json['operationName'],
value: json['value'],
condition: json['condition'],
@ -66,7 +67,7 @@ class DeviceFunctionData {
return other is DeviceFunctionData &&
other.entityId == entityId &&
other.actionExecutor == actionExecutor &&
other.function == function &&
other.functionCode == functionCode &&
other.operationName == operationName &&
other.value == value &&
other.condition == condition &&
@ -77,7 +78,7 @@ class DeviceFunctionData {
int get hashCode {
return entityId.hashCode ^
actionExecutor.hashCode ^
function.hashCode ^
functionCode.hashCode ^
operationName.hashCode ^
value.hashCode ^
condition.hashCode ^