// lib/app/models/device_model.dart
import 'package:cloud_firestore/cloud_firestore.dart';

class DeviceModel {
  final String idDevices;
  final String roomId;
  final String devicesName;

  DeviceModel({
    required this.idDevices,
    required this.roomId,
    required this.devicesName,
  });

  // From Firestore
  factory DeviceModel.fromFirestore(DocumentSnapshot doc) {
    final data = doc.data() as Map<String, dynamic>;
    return DeviceModel(
      idDevices: doc.id,
      roomId: data['room_id'] ?? '',
      devicesName: data['devices_name'] ?? '',
    );
  }

  // To Firestore
  Map<String, dynamic> toFirestore() {
    return {
      'room_id': roomId,
      'devices_name': devicesName,
    };
  }
}