class Sensor { const Sensor({ required this.id, required this.sensorId, required this.confirmed, this.name, this.roomId, this.x, this.y, }); final int id; final String sensorId; // BLE MAC / provisioning device ID final bool confirmed; // true once seen on MQTT final String? name; // human-readable label final int? roomId; final double? x; // room relative final double? y; // room relative bool get isPlaced => roomId != null && x != null && y != null; String get displayName => name ?? sensorId; factory Sensor.fromJson(Map json) => Sensor( id: json['id'] as int, sensorId: json['sensor_id'] as String, confirmed: json['confirmed'] as bool, name: json['name'] as String?, roomId: json['room_id'] as int?, x: (json['x'] as num?)?.toDouble(), y: (json['y'] as num?)?.toDouble(), ); Sensor copyWith({ String? name, int? roomId, double? x, double? y, double? rssiRef, }) => Sensor( id: id, sensorId: sensorId, confirmed: confirmed, name: name ?? this.name, roomId: roomId ?? this.roomId, x: x ?? this.x, y: y ?? this.y, ); }