Map<String, Object?> toJson() { final data = <String, Object?>{}; if (knockState != null) { data['knock_state'] = { 'events': knockState!.map((i) => i.toJson()).toList(), }; } return data; }