Map<String, dynamic> toJson() { final data = <String, dynamic>{}; if (sensor != null) { data['sensor'] = sensor!.toJson(); } data['value'] = value; return data; }