import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';

class WallLightStatusModel {
  final String uuid;
  final bool switch1;
  final int countDown;

  WallLightStatusModel({
    required this.uuid,
    required this.switch1,
    required this.countDown,
  });

  factory WallLightStatusModel.fromJson(String id, List<Status> jsonList) {
    late bool switch1;
    late int countDown;

    for (var status in jsonList) {
      switch (status.code) {
        case 'switch_1':
          switch1 = status.value ?? false;
          break;
        case 'countdown_1':
          countDown = status.value ?? 0;
          break;
      }
    }

    return WallLightStatusModel(
      uuid: id,
      switch1: switch1,
      countDown: countDown,
    );
  }

  WallLightStatusModel copyWith({
    String? uuid,
    bool? switch1,
    int? countDown,
  }) {
    return WallLightStatusModel(
      uuid: uuid ?? this.uuid,
      switch1: switch1 ?? this.switch1,
      countDown: countDown ?? this.countDown,
    );
  }
}
